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

View file

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