add: logger; syntax: defined drive formats; fix: ISO logic;
This commit is contained in:
parent
0ea0ea99e7
commit
4f0abc503a
1 changed files with 20 additions and 13 deletions
33
shemum
Normal file → Executable file
33
shemum
Normal file → Executable file
|
@ -7,12 +7,13 @@
|
||||||
# * qemu
|
# * qemu
|
||||||
# * sh
|
# * sh
|
||||||
# * curl
|
# * curl
|
||||||
|
# * syslog
|
||||||
|
# - logger
|
||||||
|
|
||||||
# Debug mode
|
# Debug mode
|
||||||
# To enable debug mode remove the comment.
|
# To enable debug mode remove the comment.
|
||||||
# Default: OFF
|
# Default: ON
|
||||||
#set +x
|
exec 1> >(logger -s -t $(basename $0)) 2>&1
|
||||||
|
|
||||||
# Virtual machine settings
|
# Virtual machine settings
|
||||||
RAM="512M"
|
RAM="512M"
|
||||||
|
@ -25,9 +26,10 @@ OS_NAME=$2
|
||||||
#DISK_SIZE=$3
|
#DISK_SIZE=$3
|
||||||
|
|
||||||
# Defining paths
|
# Defining paths
|
||||||
|
ROOT_PATH="$HOME/Machines"
|
||||||
ISO_PATH="$ROOT_PATH/$OS_NAME/$OS_NAME.iso"
|
ISO_PATH="$ROOT_PATH/$OS_NAME/$OS_NAME.iso"
|
||||||
IMG_PATH="$ROOT_PATH/$OS_NAME/$OS_NAME.img"
|
IMG_PATH="$ROOT_PATH/$OS_NAME/$OS_NAME.img"
|
||||||
ROOT_PATH="~/Machines"
|
|
||||||
|
|
||||||
# Defines install image repository.
|
# Defines install image repository.
|
||||||
case $OS_NAME in
|
case $OS_NAME in
|
||||||
|
@ -37,6 +39,10 @@ case $OS_NAME in
|
||||||
"debian")
|
"debian")
|
||||||
INSTALL_IMG=""
|
INSTALL_IMG=""
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
echo "$OS_NAME is not an option" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
@ -48,34 +54,35 @@ case $OPTION in
|
||||||
if [ ! -f $ISO_PATH ] && [ ! -z $INSTALL_IMG ]; then
|
if [ ! -f $ISO_PATH ] && [ ! -z $INSTALL_IMG ]; then
|
||||||
echo $INSTALL_IMG
|
echo $INSTALL_IMG
|
||||||
curl -o $ISO_PATH $INSTALL_IMG
|
curl -o $ISO_PATH $INSTALL_IMG
|
||||||
elif [ -z $INSTALL_IMG ]; then
|
elif [ ! -z $INSTALL_IMG ]; then
|
||||||
echo "Current INSTALL_IMG for $OS_NAME: $INSTALL_IMG"
|
echo "Current INSTALL_IMG for $OS_NAME: $ISO_PATH"
|
||||||
else:
|
else:
|
||||||
echo "ERROR: Enable debug mode by uncommenting: setx"
|
echo "Install image path is missing" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
qemu-system-x86_64 -boot d \
|
qemu-system-x86_64 -boot d \
|
||||||
-display curses \
|
-display curses \
|
||||||
-cdrom $ISO_PATH \
|
-drive file=$ISO_PATH,media=cdrom \
|
||||||
-hda $IMG_PATH \
|
-drive file=$IMG_PATH,format=raw \
|
||||||
-m $RAM -smp $CPU
|
-m $RAM -smp $CPU
|
||||||
;;
|
;;
|
||||||
"console")
|
"console")
|
||||||
qemu-system-x86_64 -boot c \
|
qemu-system-x86_64 -boot c \
|
||||||
-display curses \
|
-display curses \
|
||||||
-hda $IMG_PATH \
|
-drive file=$IMG_PATH,format=raw \
|
||||||
-m $RAM -smp $CPU
|
-m $RAM -smp $CPU
|
||||||
;;
|
;;
|
||||||
"start")
|
"start")
|
||||||
qemu-system-x86_64 -boot c \
|
qemu-system-x86_64 -boot c \
|
||||||
-hda $IMG_PATH \
|
-display none \
|
||||||
|
-drive file=$IMG_PATH,format=raw \
|
||||||
-m $RAM -smp $CPU
|
-m $RAM -smp $CPU
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: shemum [init] <virtual machine name> <disk size>"
|
echo "Usage: shemum [init] <virtual machine name> <disk size>"
|
||||||
echo " init initialize a virtual machine"
|
echo " init initialize a virtual machine"
|
||||||
echo " start start a QEMU virtual machine"
|
echo " start start a QEMU virtual machine without console output"
|
||||||
echo " console start a QEMU virtual machine"
|
echo " console start a QEMU virtual machine with console output"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue