fixes for install mode

This commit is contained in:
betcher 2022-11-01 13:27:30 +03:00
parent 0584369b0d
commit 0828ce2bd4
2 changed files with 25 additions and 28 deletions

49
qemoo
View file

@ -2,12 +2,16 @@
ACTION='run' # what to do
IMG='none' # name of image to boot
QCOW2='none' # name for qcow2 image to install
SIZE='10' # size for qcow2 image to install
SIZE='12' # size for qcow2 image to install
RAM='auto' # ram for machine
QEMUADD='' # additional parameters for qemu
EFI_FIRMWARE="-bios /usr/share/OVMF/OVMF_CODE.fd"
### init empty, not for config
EFI=''
KVM=''
INSTALL=''
###
[ -f '/ect/qemoo.cfg' ] && . /etc/qemoo.cfg
[ -f './qemoo.cfg' ] && . ./qemoo.cfg
@ -20,10 +24,10 @@ do
"-s" | "--size" ) shift : SIZE=$1 ;; # <par> size for new qcow2 (only with --install)
"-q" | "--qcow2" ) shift; QCOW2="$1" ;; # <par> name for new or existing qcow2 (only with --install)
"-m" | "--mem" ) shift ; RAM=$1 ;; # <par> size or RAM to guest machine
"-S" | "--show-cmdline" ) SHOW='yes' ;; # show qemu cmdline
"-R" | "--usb" ) REDIRUSB='yes' ;; # redirect USB drive to guest machine, useful for tokens, modems, etc.
"-e" | "--efi" | "--uefi" ) EFI="$EFI_FIRMWARE" ;; # efi instead legacy bios
"-l" | "--loop" | "--losetup" ) LOSETUP='yes' ;; # use ISO and IMG files attaching as loop device
"-L" | "--ll" | "--lowlevel" ) REDIRUSB='yes' ;; # lowlevel redirect USB drive to guest machine, useful for tokens, modems, etc.
"-e" | "--efi" | "--uefi" ) EFI="$EFI_FIRMWARE" ;; # efi instead legacy bios
"-l" | "--loop" | "--losetup" ) LOSETUP='yes' ;; # use ISO and IMG files attaching as loop device
"-S" | "--show-cmdline" ) SHOW='yes' ;; # do not run qemu, show qemu cmdline only
"-h" | "--help" ) # this help
echo "Usage: $0 /path/to/image <parameters>"
cat $0 |sed -n '/).*#.*/s/).*#/ - /p' |grep -v cat
@ -35,6 +39,15 @@ do
shift
done
run() {
cmdline="$@"
if [ "$SHOW" ] ; then
echo $cmdline
else
$cmdline
fi
}
checkImg(){
if [ "$IMG" == 'none' ] ; then
echo "No image name" 1>&2
@ -156,14 +169,7 @@ COMMON="$QEMU $KVM $EFI \
[ "$REDIRUSB" ] && usbDev="$(checkUSB)"
run() {
cmdline="$@"
if [ "$SHOW" ] ; then
echo $cmdline
else
$cmdline
fi
}
[ "$ACTION" == 'install' ] && INSTALL="-drive file=$qImg,cache=none"
case $type in
'virt' )
@ -171,31 +177,22 @@ case $type in
cmdline="
-boot c \
-drive $DRIVEPARS"
run $COMMON $cmdline $QEMUADD
;;
'blockdev')
echo "Block device: $IMG"
cmdline="
-boot c \
${usbDev:--drive $DRIVEPARS}"
run $COMMON $cmdline $QEMUADD
;;
'iso')
echo "ISO: $IMG"
if [ $ACTION == 'install' ] ; then
cmdline="
-boot d \
-drive $DRIVEPARS,media=cdrom \
-drive file=$qImg,cache=none"
else
cmdline="
-boot d \
-drive $DRIVEPARS,media=cdrom"
fi
run $COMMON $cmdline $QEMUADD
cmdline="
-boot d \
-drive $DRIVEPARS,media=cdrom"
;;
*)
echo "unknown type: $type"
exit ${LINENO}
esac
run $COMMON $cmdline $INSTALL $QEMUADD

View file

@ -1,7 +1,7 @@
Summary: Wrapper for qemu to easy run guest machines
Name: qemoo
Version: 0.2
Release: 2
Version: 0.4
Release: 1
License: GPLv2+
Group: System/Base
Url: https://abf.io/import/qemoo