initial commit
This commit is contained in:
commit
0ea0ea99e7
1 changed files with 82 additions and 0 deletions
82
shemum
Normal file
82
shemum
Normal file
|
@ -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] <virtual machine name> <disk size>"
|
||||
echo " init initialize a virtual machine"
|
||||
echo " start start a QEMU virtual machine"
|
||||
echo " console start a QEMU virtual machine"
|
||||
esac
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue