Skip to content
Snippets Groups Projects
Commit 20b6ee9e authored by Marty Kandes's avatar Marty Kandes
Browse files

Recreate uninstall command to remove a source-based install of Singularity

parent 9b2bfa67
No related branches found
No related tags found
No related merge requests found
...@@ -60,8 +60,8 @@ University of California, San Diego ...@@ -60,8 +60,8 @@ University of California, San Diego
## Version ## Version
1.8.4 1.8.5
## Last Updated ## Last Updated
Thursday, August 12th, 2021 Wednesday, August 18th, 2021
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
# #
# DESCRIPTION # DESCRIPTION
# #
# A bash script to help users work with Singularity on their Linux # A bash shell utility to help you work with Singularity (and the
# desktop, laptop, or virtual machine. # definition files within the naked-singularity repository) on your
# Linux desktop, laptop, or virtual machine.
# #
# USAGE # USAGE
# #
...@@ -17,7 +18,7 @@ ...@@ -17,7 +18,7 @@
# #
# LAST UPDATED # LAST UPDATED
# #
# Friday, July 23rd, 2021 # Wednesday, Auguest 18th, 2021
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -26,7 +27,7 @@ source log.sh ...@@ -26,7 +27,7 @@ source log.sh
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# naked::install # naked::install
# #
# Install Singularity (from source). # Installs Singularity from source [or via rpm].
# #
# Globals: # Globals:
# #
...@@ -38,8 +39,8 @@ source log.sh ...@@ -38,8 +39,8 @@ source log.sh
# #
# Returns: # Returns:
# #
# True (0) if Singularity is installed sucessfully. False (1) # True (0) if Singularity is installed sucessfully.
# if the installation fails. # False (1) if the installation of Singularity fails.
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -54,6 +55,10 @@ naked::install() { ...@@ -54,6 +55,10 @@ naked::install() {
while (("${#}" > 0)); do while (("${#}" > 0)); do
case "${1}" in case "${1}" in
-s | --singularity )
singularity_version="${2}"
shift 2
;;
-g | --go ) -g | --go )
go_version="${2}" go_version="${2}"
shift 2 shift 2
...@@ -62,10 +67,6 @@ naked::install() { ...@@ -62,10 +67,6 @@ naked::install() {
use_rpm=0 use_rpm=0
shift 1 shift 1
;; ;;
-s | --singularity )
singularity_version="${2}"
shift 2
;;
*) *)
log::error "Command-line option ${1} not recognized or not supported." log::error "Command-line option ${1} not recognized or not supported."
return 1 return 1
...@@ -222,6 +223,80 @@ naked::install() { ...@@ -222,6 +223,80 @@ naked::install() {
} }
# ----------------------------------------------------------------------
# naked::uninstall
#
# Removes an existing source [or rpm-based] installation of Singularity.
#
# Globals:
#
# N/A
#
# Arguments:
#
# @
#
# Returns:
#
# True (0) if Singularity is uninstalled and removed sucessfully.
# False (1) if the removal of Singularity fails.
#
# ----------------------------------------------------------------------
naked::uninstall() {
local singularity_prefix='/usr/local'
local -i use_rpm=1
local os_release_id=''
local os_release_version_id=''
while (("${#}" > 0)); do
case "${1}" in
-p | --prefix )
singularity_prefix="${2}"
shift 2
;;
-r | --rpm )
use_rpm=0
shift 1
;;
*)
log::error "Command-line option ${1} not recognized or not supported."
return 1
esac
done
log::output 'Checking if Singularity is already installed ...'
singularity --version > /dev/null 2>&1
if [[ "${?}" -eq 0 ]]; then
log::output "Singularity is installed: $(singularity --version)"
else
log::error 'Singularity is not installed.'
return 1
fi
log::output 'Uninstalling Singularity ...'
sudo rm -rf "${singularity_prefix}/libexec/singularity"
sudo rm -rf "${singularity_prefix}/var/singularity"
sudo rm -rf "${singularity_prefix}/etc/singularity"
sudo rm -rf "${singularity_prefix}/bin/singularity"
sudo rm -rf "${singularity_prefix}/bin/run-singularity"
sudo rm -rf "${singularity_prefix}/etc/bash_completion.d/singularity"
log::output 'Checking if Singularity was uninstalled successfully ...'
which singularity
if [[ "${?}" -eq 0 ]]; then
log:error 'Singularity was NOT uninstalled!'
return 1
fi
log::output 'Singularity was uninstalled successfully!'
return 0
}
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# naked::help # naked::help
# #
...@@ -265,8 +340,8 @@ naked::help() { ...@@ -265,8 +340,8 @@ naked::help() {
# #
# Returns: # Returns:
# #
# True (0) if the script executes without issue. False (1) if the # True (0) if the script executes without issue.
# script fails to executre properly. # False (1) if the script fails to executre properly.
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -290,6 +365,14 @@ naked::main() { ...@@ -290,6 +365,14 @@ naked::main() {
exit 1 exit 1
fi fi
elif [[ "${naked_command}" = 'uninstall' ]]; then
naked::uninstall "${@}"
if [[ "${?}" -ne 0 ]]; then
log::error 'Failed to run uninstall command.'
exit 1
fi
elif [[ "${naked_command}" = 'help' || \ elif [[ "${naked_command}" = 'help' || \
"${naked_command}" = '-h' || \ "${naked_command}" = '-h' || \
"${naked_command}" = '--help' ]]; then "${naked_command}" = '--help' ]]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment