summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRamón M. Gómez <ramongomez@us.es>2020-02-18 11:09:48 +0100
committerRamón M. Gómez <ramongomez@us.es>2020-02-18 11:09:48 +0100
commit1f6fd0684cd1cb3ee321307b8d68ed4c3fde074b (patch)
tree4e3511e521090b73eeabba4099363f0b55244333
parentda6986dc0a5750751d28a699d077adba5af5c628 (diff)
#957: Script `importimage` can use the `version` function.
-rwxr-xr-xrepoman/bin/importimage15
1 files changed, 7 insertions, 8 deletions
diff --git a/repoman/bin/importimage b/repoman/bin/importimage
index c5ac8eba..8fed1196 100755
--- a/repoman/bin/importimage
+++ b/repoman/bin/importimage
@@ -1,11 +1,11 @@
#!/bin/bash
#/**
#@file importimage
-#@usage importimage [str_user] str_repo str_imagename
+#@usage importimage [User] Repo ImageName
#@brief Imports an image file from other repository
-#@param str_user username to access the remote repository (local user, by default)
-#@param str_repo repository IP address or hostaname
-#@param str_imagename image name to download
+#@param User username to access the remote repository (local user, by default)
+#@param Repo repository IP address or hostaname
+#@param ImageName image name to download
#@warning Program will request the repository REST token.
#@version 1.1.1 - Initial version
#@author Ramón M. Gómez, ETSII Universidad de Sevilla
@@ -17,8 +17,7 @@
# Variables.
-PROG="$(basename "$0")"
-OPENGNSYS="/opt/opengnsys"
+OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
REPODIR="$OPENGNSYS/images"
REPOCONF="$OPENGNSYS/etc/ogAdmRepo.cfg"
SERVERCONF="$OPENGNSYS/etc/ogAdmServer.cfg"
@@ -29,7 +28,7 @@ source $REPOCONF &>/dev/null
[ "$RUN_OGADMSERVER" == "yes" ] && source $SERVERCONF &>/dev/null
# Functions.
-source $OPENGNSYS/lib/ogfunctions.sh
+source $OPENGNSYS/lib/ogfunctions.sh || exit 1
# Main program.
@@ -42,7 +41,7 @@ source $OPENGNSYS/lib/ogfunctions.sh
case $# in
2) USERNAME="$SUDO_USER"; REPO="$1"; IMAGE="$2" ;;
3) USERNAME="$1"; REPO="$2"; IMAGE="$3" ;;
- *) [ "$*" == "help" ] && help || raiseError usage
+ *) [[ $* =~ ^(help|version)$ ]] && $* || raiseError usage
esac
[ "${REPO,,}" == "${HOSTNAME,,}" ] || [ "${REPO,,}" == "localhost" ] || [[ ${REPO} =~ ^127\. ]] || [ "${REPO,,}" == "${IPlocal,,}" ] && raiseError access "Cannot import from local repository."