Skip to content
Snippets Groups Projects
  • Josef Hrabal's avatar
    4a047b13
    modified: bin/image-exec · 4a047b13
    Josef Hrabal authored
    	modified:   bin/image-load
    	modified:   bin/image-mpi
    	modified:   bin/image-run
    	modified:   bin/image-shell
    	modified:   bin/image-update
    	modified:   install/CENTOS7
    	modified:   install/CONFIG
    4a047b13
    History
    modified: bin/image-exec
    Josef Hrabal authored
    	modified:   bin/image-load
    	modified:   bin/image-mpi
    	modified:   bin/image-run
    	modified:   bin/image-shell
    	modified:   bin/image-update
    	modified:   install/CENTOS7
    	modified:   install/CONFIG
image-update 1.21 KiB
#!/bin/bash

if [ -z "IMAGE_ROOT" ] || [ -z "IMAGE_OS" ] || [ -z "IMAGE_VERSION" ]; then
    echo -e "\e[31mAn error occured, exiting...\e[0m"
    exit 1
fi

APPS_VERSION=$(ls -t $IMAGE_ROOT | grep .img | head -1)

LOCAL_VERSION=$(ls $HOME/.singularity/images | grep $IMAGE_OS-$IMAGE_VERSION* | head -1)

if [ "$LOCAL_VERSION" \< "$APPS_VERSION" ]; then
    echo -ne "\e[33mNew version of CentOS image was found.\e[0m (\e[33mNew:\e[0m $APPS_VERSION \e[33mOld:\e[0m $LOCAL_VERSION)\nDo you want to update local copy? (\e[31mWARNING all user modification will be deleted\e[0m) [y/N]: "
    read CONTINUE
    if [ "$CONTINUE" == "y" ] || [ "$CONTINUE" == "Y" ]; then
        echo -ne "\e[33mUpdating image \e[0m "
        rsync --progress -h $IMAGE_ROOT/$APPS_VERSION $HOME/.singularity/images/$APPS_VERSION
        echo -e "\e[32mNew version is ready.\e[0m ($HOME/.singularity/images/$APPS_VERSION)"
        unset IMAGE_PATH_LOCAL
        export IMAGE_PATH_LOCAL="$HOME/.singularity/images/$APPS_VERSION"
        [ -f $HOME/.singularity/images/$LOCAL_VERSION ] && rm $HOME/.singularity/images/$LOCAL_VERSION 
    else
	echo "Exiting..."
    fi
else
    echo -e "\e[33mYou already have the newest version of\e[0m $IMAGE_OS \e[33mimage.\e[0m"
fi