commit 0ea0ea99e7de2ed3d84bfbf5c2d70a35d9698a54 Author: Your Name Date: Wed Sep 25 23:03:33 2024 +0200 initial commit diff --git a/shemum b/shemum new file mode 100644 index 0000000..050fde1 --- /dev/null +++ b/shemum @@ -0,0 +1,82 @@ +#!/usr/bin/env sh +# +# Author: Adrian Erik Hoemann +# Date: 9.18.2024 +# +# Dependencies: +# * qemu +# * sh +# * curl + + +# Debug mode +# To enable debug mode remove the comment. +# Default: OFF +#set +x + +# Virtual machine settings +RAM="512M" +CPU="1" +DISK_SIZE="8G" + +# Arguments +OPTION=$1 +OS_NAME=$2 +#DISK_SIZE=$3 + +# Defining paths +ISO_PATH="$ROOT_PATH/$OS_NAME/$OS_NAME.iso" +IMG_PATH="$ROOT_PATH/$OS_NAME/$OS_NAME.img" +ROOT_PATH="~/Machines" + +# Defines install image repository. +case $OS_NAME in + "openbsd") + INSTALL_IMG="https://cdn.openbsd.org/pub/OpenBSD/7.5/i386/cd75.iso" + ;; + "debian") + INSTALL_IMG="" + ;; +esac + +# 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: $INSTALL_IMG" + else: + echo "ERROR: Enable debug mode by uncommenting: setx" + exit 1 + fi + qemu-system-x86_64 -boot d \ + -display curses \ + -cdrom $ISO_PATH \ + -hda $IMG_PATH \ + -m $RAM -smp $CPU + ;; + "console") + qemu-system-x86_64 -boot c \ + -display curses \ + -hda $IMG_PATH \ + -m $RAM -smp $CPU + ;; + "start") + qemu-system-x86_64 -boot c \ + -hda $IMG_PATH \ + -m $RAM -smp $CPU + ;; + *) + echo "Usage: shemum [init] " + echo " init initialize a virtual machine" + echo " start start a QEMU virtual machine" + echo " console start a QEMU virtual machine" +esac + + +