commit
15fc39a355
1 changed files with 57 additions and 30 deletions
87
shemum
87
shemum
|
@ -42,48 +42,75 @@ case $OS_NAME in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Functions
|
||||||
|
|
||||||
|
# Virtual machine removal
|
||||||
|
remove_func function {
|
||||||
|
rm -r $ROOT_PATH/$OS_NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
# Virtual machine start without a console
|
||||||
|
start_func function {
|
||||||
|
qemu-system-x86_64 -boot c \
|
||||||
|
-display none \
|
||||||
|
-drive file=$IMG_PATH,format=raw \
|
||||||
|
-m $RAM -smp $CPU
|
||||||
|
}
|
||||||
|
|
||||||
|
# Virtual machine start with a console
|
||||||
|
console_func function {
|
||||||
|
qemu-system-x86_64 -boot c \
|
||||||
|
-display curses \
|
||||||
|
-drive file=$IMG_PATH,format=raw \
|
||||||
|
-m $RAM -smp $CPU
|
||||||
|
}
|
||||||
|
|
||||||
|
# Virtual machine initialization with a console
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display usage
|
||||||
|
usage_func function {
|
||||||
|
printf "Usage: shemum [init] <virtual machine name> <disk size>"
|
||||||
|
printf " init initialize a virtual machine"
|
||||||
|
printf " start start a QEMU virtual machine without console output"
|
||||||
|
printf " console start a QEMU virtual machine with console output"
|
||||||
|
printf " remove remove virtual machine directory and all it's contents"
|
||||||
|
}
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
# Initializes the VM and starts the installer image.
|
# Initializes the VM and starts the installer image.
|
||||||
"init")
|
"init")
|
||||||
mkdir -p "$ROOT_PATH/$OS_NAME"
|
init_func
|
||||||
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
|
|
||||||
;;
|
;;
|
||||||
"console")
|
"console")
|
||||||
qemu-system-x86_64 -boot c \
|
console_func
|
||||||
-display curses \
|
|
||||||
-drive file=$IMG_PATH,format=raw \
|
|
||||||
-m $RAM -smp $CPU
|
|
||||||
;;
|
;;
|
||||||
"start")
|
"start")
|
||||||
qemu-system-x86_64 -boot c \
|
start_func
|
||||||
-display none \
|
|
||||||
-drive file=$IMG_PATH,format=raw \
|
|
||||||
-m $RAM -smp $CPU
|
|
||||||
;;
|
;;
|
||||||
"remove")
|
"remove")
|
||||||
rm -r $ROOT_PATH/$OS_NAME
|
remove_func
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: shemum [init] <virtual machine name> <disk size>"
|
usage_func
|
||||||
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
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue