From 442ff6bcbc557fee7f27613eba348e477ecfcd85 Mon Sep 17 00:00:00 2001 From: BonzaiBrains <133261117+BonzaiBrains@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:56:44 +0100 Subject: [PATCH] add: init function --- shemum | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/shemum b/shemum index 1eb999c..e9bf6e4 100755 --- a/shemum +++ b/shemum @@ -65,26 +65,30 @@ console_func function { -m $RAM -smp $CPU } +init_func function { + mkdir -p "$ROOT_PATH/$OS_NAME" + qemu-img create $IMG_PATH $DISK_SIZE + if [ ! -f $ISO_PATH ] && [ ! -z $INSTALL_IMG ]; then + echo $INSTALL_IMG + curl -o $ISO_PATH $INSTALL_IMG + elif [ ! -z $INSTALL_IMG ]; then + echo "Current INSTALL_IMG for $OS_NAME: $ISO_PATH" + else: + echo "Install image path is missing" >&2 + exit 1 + fi + qemu-system-x86_64 -boot d \ + -display curses \ + -drive file=$ISO_PATH,media=cdrom \ + -drive file=$IMG_PATH,format=raw \ + -m $RAM -smp $CPU +} + # Options case $OPTION in # Initializes the VM and starts the installer image. "init") - mkdir -p "$ROOT_PATH/$OS_NAME" - qemu-img create $IMG_PATH $DISK_SIZE - if [ ! -f $ISO_PATH ] && [ ! -z $INSTALL_IMG ]; then - echo $INSTALL_IMG - curl -o $ISO_PATH $INSTALL_IMG - elif [ ! -z $INSTALL_IMG ]; then - echo "Current INSTALL_IMG for $OS_NAME: $ISO_PATH" - else: - echo "Install image path is missing" >&2 - exit 1 - fi - qemu-system-x86_64 -boot d \ - -display curses \ - -drive file=$ISO_PATH,media=cdrom \ - -drive file=$IMG_PATH,format=raw \ - -m $RAM -smp $CPU + init_func ;; "console") console_func