Skip to content

Instantly share code, notes, and snippets.

@vsoch
Last active May 8, 2019 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsoch/7a7d41d166a846badf723b1462a9db46 to your computer and use it in GitHub Desktop.
Save vsoch/7a7d41d166a846badf723b1462a9db46 to your computer and use it in GitHub Desktop.
An example of setting a custom environment variable already defined in the container
Bootstrap: docker
From: centos:7
# sudo singularity build lamps.simg Singularity
%environment
now=`date '+%Y_%m_%d'`
hostname=`hostname`
APPNAME="lammps"
RESULTS_DIR=${HOME}/${APPNAME}
LOG="${hostname}_${APPNAME}_${now}"
RESULTS="${hostname}_${APPNAME}_${now}.results"
SYSCONFIG="${hostname}_${APPNAME}_${now}.sysconfig"
APPINFO="${hostname}_${APPNAME}_${now}.appinfo"
export APPNAME LOG RESULTS SYSCONFIG APPINFO now hostname RESULTS_DIR
%apprun lammps
echo "${SCIF_APPNAME} is running."
WORKDIR=${SCIF_APPROOT}
if [ -n "$CUSTOM_RESULTS_DIR" ]; then
RESULTS_DIR=$CUSTOM_RESULTS_DIR
else
RESULTS_DIR=${HOME}/${APPNAME}
fi
if [ ! -x "$RESULTS_DIR" ]; then
mkdir -p $RESULTS_DIR
fi
cd $WORKDIR
echo "Single node Output file is $RESULTS and log is $LOG and results dir is $RESULTS_DIR" |tee $RESULTS_DIR/$RESULTS
%post
yum install -y sudo wget vi which
yum install -y hostname lscpu uptime redhat-lsb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment