Skip to content

Commit

Permalink
Fixing issue#8: removing docker/sing images at uninstall time
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiat committed Jan 15, 2020
1 parent 22fb0a8 commit 5f0f140
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
3 changes: 2 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ if [ -d $user_home/.monet ]; then
echo "EXITING: MONET WAS NOT RE-INSTALLED."
exit 0
else
echo "invalid option selected"
echo ""
echo "ERROR: invalid option selected."
echo "EXITING: MONET WAS NOT RE-INSTALLED."
exit 0
fi
Expand Down
63 changes: 60 additions & 3 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,66 @@
###############################################################################

echo
echo "Uninstalling the MONET"
echo
echo "Uninstalling MONET"
echo

user_home=$HOME

if [ ! -d $user_home/.monet ]; then
echo "MONET is not installed on the system. Nothing to do."
echo "FINISHED"
exit 1
fi

remove_docker_images(){
docker --help > /tmp/docker_test 2>&1 # is docker installed?
if [ $? -eq "0" ]; then docker_installed=true; else docker_installed=false; fi
if $docker_installed; then
rm -f /tmp/docker_rmi
sudo docker rm K1-container >> /tmp/docker_rmi 2>&1
sudo docker rmi k1-image >> /tmp/docker_rmi 2>&1
sudo docker rm M1-container >> /tmp/docker_rmi 2>&1
sudo docker rmi m1-image >> /tmp/docker_rmi 2>&1
sudo docker rm R1-container >> /tmp/docker_rmi 2>&1
sudo docker rmi r1-image >> /tmp/docker_rmi 2>&1
echo "- Docker images were removed (see /tmp/docker_rmi for details)"
fi
}

remove_singularity_images(){
singularity --help > /tmp/singularity_test 2>&1 # is singularity installed?
if [ $? -eq "0" ]; then singularity_installed=true; else singularity_installed=false; fi
if $singularity_installed; then
rm -f /tmp/singularity_rmi
# the whole .monet folder will later be removed; keeping this for consistency/clarity
rm $user_home/.monet/containers/K1/singularity/K1-image.img >> /tmp/singularity_rmi 2>&1
rm $user_home/.monet/containers/K1/singularity/M1-image.img >> /tmp/singularity_rmi 2>&1
rm $user_home/.monet/containers/K1/singularity/R1-image.img >> /tmp/singularity_rmi 2>&1
echo "- Singularity images were removed (see /tmp/singularity_rmi for details)"
fi
}

# optionally remove virtualization images
# (if they had been created by running the corresponding method)
read -p "Would you like to remove Docker/Singularity images/containers? [y|n] " -n 1 -r
echo ""
if [[ $REPLY =~ ^[y]$ ]]; then
remove_docker_images
remove_singularity_images
echo ""
elif [[ $REPLY =~ ^[n]$ ]]; then
echo "Docker images/containers were not removed."
echo ""
else
echo ""
echo "ERROR: invalid option selected."
echo "EXITING: MONET WAS NOT UNINSTALLED."
exit 0
fi


# remove MONET installation folder
rm -rf ~/.monet
echo FINISHED: monet was UNINSTALLED SUCCESSFULLY.

echo FINISHED: MONET was UNINSTALLED SUCCESSFULLY.
echo

0 comments on commit 5f0f140

Please sign in to comment.