Skip to content

singularity installer script #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions install
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

# This script install singularity

function print_usage () {
echo "This script download singularity, compile and installs it"
echo "root prividge is needed as some files need to be installed with suid. eg:"
echo "sudo ./install will install to /usr/local/singularity-\$BUILD"
echo "sudo ./install --prefix=/opt --build=2.4.alpha will install to /opt/singularity-2.4.alpha"
}

### process command line arguments ###
# option parsing ref:
# https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
for i in "$@"; do
case $i in
-p=*|--prefix=*)
PREFIX="${i#*=}"
shift # past argument=value
;;
-b=*|--build=*)
#BUILD="${i#*=}"
BUILD="${i#*=}"
shift # past argument=value
;;
-h|--help)
print_usage
exit 255
;;
*)
echo "Unknown argument. Use -h for help"
exit 255
;;
esac
done



### actual install ###

PREFIX="${PREFIX:-/usr/local}" # default install to /usr/local unless otherwise specified
#VER="{VER:-}"
if [[ x${BUILD} == "x" ]] ; then
BUILD=$(date "+%Y.%m%d")
fi
INSTALLDIR=${PREFIX}/singularity-${BUILD}

echo "This script install singularity to ${INSTALLDIR}"
echo "Press ^C in the next 15 seconds to cancel"
sleep 15
#echo "Press ^C to cancel or the ANY key to continue..."
#read CONFIRM
echo "installing..."



if [[ ! -d ${INSTALLDIR} ]]; then
mkdir -p ${INSTALLDIR}
EXITCODE=$?
if [[ $EXITCODE -gt 0 ]]; then
echo "Unable to create ${INSTALLDIR}. Exiting."
exit $EXITCODE
fi
fi

GITSOURCE=${INSTALLDIR}/github
if [[ ! -d ${GITSOURCE} ]] ; then
# singularity never pulled from github, setting it up now
mkdir ${GITSOURCE}
cd ${GITSOURCE}
git clone https://github.com/singularityware/singularity.git
else
# update code before install
cd ${GITSOURCE}/singularity
git pull
fi

cd ${GITSOURCE}/singularity
./autogen.sh
EXITCODE=$?
if [[ $EXITCODE -gt 0 ]]; then
echo "autogen didn't work correctly. "
echo "Please make sure the following packages are installed: libtool automake autoconf"
exit $EXITCODE
fi
./configure --prefix=${INSTALLDIR}
make
sudo make install
EXITCODE=$?
if [[ $EXITCODE -eq 0 ]]; then
echo "Done. Singularity installed to ${INSTALLDIR}."
else
echo "Something didn't go right, Singularity install exits with ${EXITCODE}."
fi