add: value sourcing

This commit is contained in:
ahoemann 2024-10-08 12:56:46 +02:00
parent 4fd0f57777
commit 6818ee3e1d
2 changed files with 15 additions and 8 deletions

4
.env Normal file
View file

@ -0,0 +1,4 @@
# Virtual machine settings
RAM="512M"
CPU="1"
DISK_SIZE="8G"

15
shemum
View file

@ -15,21 +15,20 @@
# Default: ON
#:exec 1> >(logger -s -t $(basename $0)) 2>&1
# Virtual machine settings
RAM="512M"
CPU="1"
DISK_SIZE="8G"
# Arguments
OPTION=$1
OS_NAME=$2
#DISK_SIZE=$3
# Defining paths
ROOT_PATH="$HOME/Machines"
ISO_PATH="$ROOT_PATH/$OS_NAME/$OS_NAME.iso"
IMG_PATH="$ROOT_PATH/$OS_NAME/$OS_NAME.img"
# Sources defualt values
. ".env"
# Sources virtual machine specific values
. "$ROOT_PATH/$OS_NAME/.env"
# Defines install image repository.
case $OS_NAME in
@ -78,11 +77,15 @@ case $OPTION in
-drive file=$IMG_PATH,format=raw \
-m $RAM -smp $CPU
;;
"remove")
rm -r $ROOT_PATH/$OS_NAME
;;
*)
echo "Usage: shemum [init] <virtual machine name> <disk size>"
echo " init initialize a virtual machine"
echo " start start a QEMU virtual machine without console output"
echo " console start a QEMU virtual machine with console output"
echo " remove remove virtual machine directory and all it's contents"
esac