summaryrefslogtreecommitdiffstats
path: root/packager/openslx
diff options
context:
space:
mode:
Diffstat (limited to 'packager/openslx')
-rwxr-xr-xpackager/openslx48
1 files changed, 14 insertions, 34 deletions
diff --git a/packager/openslx b/packager/openslx
index 6a75fc47..a71a1db6 100755
--- a/packager/openslx
+++ b/packager/openslx
@@ -10,25 +10,6 @@
#
# ------------------------------------------------------------------------------
#
-# OpenSLX-NG Functions
-#
-# ------------------------------------------------------------------------------
-pinfo() {
- echo -e "\033[38;5;10m[info]\033[0m $@"
-}
-
-perror() {
- echo -e "\033[38;5;9m[error]\033[0m $@"
- kill "$SELF_PID"
- exit 1
-}
-
-print_usage() {
- perror "$ARG0 <remote_ip> <stage4_sync_dir> <target_qcow2_container>"
-}
-
-# ------------------------------------------------------------------------------
-#
# OpenSLX-NG Main Code
#
# ------------------------------------------------------------------------------
@@ -38,11 +19,15 @@ declare -rg SELF="$(readlink -f "$ARG0")"
declare -rg ROOT_DIR="$(dirname "${SELF}")"
declare -rg SELF_PID="$$"
+# let's keep it simple for now, just source our config/functions file
+. "${ROOT_DIR}/$ARG0".functions || perror "Could not source functions."
+. "${ROOT_DIR}/$ARG0".config || perror "Could not source config."
+
# root check
if [ "$(id -u)" -ne 0 ]; then
perror "ERROR: You need to be root to use this toolkit."
else
- pinfo ""
+ banner
fi
# do we even have tools?
@@ -50,19 +35,14 @@ for TOOL in qemu-img qemu-nbd mkfs.ext4; do
which $TOOL &>/dev/null || perror "Could not find '$TOOL'."
done
-# let's keep it simple for now, just source our main functions file
-. "${ROOT_DIR}/$ARG0".functions || perror "Could not source functions."
-
-# ok, now check that we have 3 args
-[ $# -ne 3 ] && print_usage
-# even though functions check their parameter, we also do it to be safe.
-valid_ip "$1" || perror "'$1' is not a valid IP adress, aborting..."
-[ ! -d "$2" ] || perror "'$2' already exists, aborting..."
-[ ! -f "$3" ] || perror "'$3' already exists, aborting..."
+read_params $@
+if [ "x$ACTION" == "xCLONE" ]; then
+ clone_stage4 || perror "Cloning stage4 failed with: $?"
+elif [ "x$ACTION" == "xPACKAGE" ]; then
+ pack_qcow2 || perror "Packing as QCoW2 failed with: $?"
+else
+ pwarning "No action given."
+ print_usage
+fi
-# all good, let's start
-pinfo " ## RUNNING ##"
-clone_stage4 $1 $2 || perror "Failed to clone stage4 with: $1 $2"
-export_qcow2 $2 $3 || perror "Failed to export stage4 with: $2 $3"
-pinfo " ## COMPLETE ##"