diff options
author | Casper <me@skylarcloud.xyz> | 2024-12-23 17:13:45 -0700 |
---|---|---|
committer | Casper <me@skylarcloud.xyz> | 2024-12-23 17:13:45 -0700 |
commit | 01a33ab0913d439150065ac23644c4f140ff8917 (patch) | |
tree | 9ad71bd7e6f5a5aad2c2cdbff4bb75de12565998 /qmenu/qmenu_vm/fqvm_prefs | |
parent | 7b5a0e9e88f015cb68a46bb657661f4663e287af (diff) |
added qmenu!
Diffstat (limited to 'qmenu/qmenu_vm/fqvm_prefs')
-rw-r--r-- | qmenu/qmenu_vm/fqvm_prefs | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/qmenu/qmenu_vm/fqvm_prefs b/qmenu/qmenu_vm/fqvm_prefs new file mode 100644 index 0000000..0609923 --- /dev/null +++ b/qmenu/qmenu_vm/fqvm_prefs @@ -0,0 +1,155 @@ +property=1 + +while [ -n "$property" ]; do + + property=$(qvm-prefs "$qube" | dmenu-unlinked -l 45 -p "$qube:" | cut -f1 -d\ ) + + if [ -n "$property" ]; then + + case $property in + + autostart) + + value=$(printf 'False\nTrue' | dmenu-unlinked -i -p "Set autostart of $qube to:");; + + debug) + + value=$(printf 'False\nTrue' | dmenu-unlinked -i -p "Set debug mode of $qube to:");; + + default_dispvm) + + if [ -z "$LIST_DISPTEMP" ]; then + + # [mediocre] Look up disposable templates in a very slow way because qvm-ls does not offer a flag for them + for n in $(qvm-ls --raw-data -O NAME,FLAGS | grep '|a.....-.$' | cut -d '|' -f1); do + + qvm-prefs "$n" template_for_dispvms | grep -q True && + + LIST_DISPTEMP="$LIST_DISPTEMP\n$n" + done + fi + + value=$(printf "(Default)\n(None)$LIST_DISPTEMP" | dmenu-unlinked -l 50 -p "Select default dispvm for $qube:");; + + default_user) + + value=$(echo --default | dmenu-unlinked -p "Enter the name of the default user for $qube:");; + + include_in_backups) + + value=$(printf 'False\nTrue' | dmenu-unlinked -i -p "Include $qube in backups?");; + + kernel) + + value=$(printf "(Default)\n(None)" | dmenu-unlinked -l 2 -p "Enter the kernel to be used by $qube:");; + + kernelopts) + + value=$(echo --default | dmenu-unlinked -p "Enter the kernel options for $qube:") && + + nyprompt "Set kernel options for $qube to \"$value\"?" || unset value;; + + label) + + if qvm-check -q --running "$qube"; then + + echo Go back... | dmenu-unlinked -p "$qube needs to be powered off, in order to change its label." > /dev/null 2>&1 + else + value=$(printf 'Purple\nBlue\nGray\nGreen\nYellow\nOrange\nRed\nBlack' | dmenu-unlinked -i -l 8 -p "Select label for $qube:" | awk '{print tolower($0)}') + fi;; + + mac) + + value=$(echo --default | dmenu-unlinked -p "Enter the MAC address for $qube:") && + + nyprompt "Set MAC address of $qube to $value?" || unset value;; + + maxmem) + + value=$(echo --default | dmenu-unlinked -p "Enter the maximum amount of memory in MB to be allocated to $qube. Setting it to 0 will disable dynamic memory balancing.") && + + if nyprompt "Set maximum memory of $qube to $value MB?"; then + + # For linux qubes, initial memory can not be less than one tenth of maxmem + # so we will automatically set the minimum allowed value. + # Users can still overwrite this manually via fqvm_prefs - memory. + + minmem=$(( $value / 10 )) + + [ "$(qvm-prefs $qube memory)" -lt "$minmem" ] && qvm-prefs "$qube" memory "$minmem" + else + unset value + fi;; + + memory) + + value=$(echo --default | dmenu-unlinked -p "Enter the amount of initial memory in MB to be allocated to $qube:") && + + nyprompt "Set initial memory of $qube to $value MB?" || unset value;; + + netvm) + + get_list netvm + + value=$(printf "(Default)\n(None)\n$list" | dmenu-unlinked -l 50 -p "Select netvm for $qube:");; + + provides_network) + + value=$(printf 'False\nTrue' | dmenu-unlinked -i -p "Should $qube provide networking to other qubes?");; + + qrexec_timeout) + + value=$(echo --default | dmenu-unlinked -p "Enter the time in seconds, after which qrexec connection attempts are deemed a failure for $qube:") && + + nyprompt "Set qrexec timeout for $qube to $value seconds?" || unset value;; + + shutdown_timeout) + + value=$(echo --default | dmenu-unlinked -p "Enter the time in seconds to wait for shutdown, after which $qube may be forcefully powered off:") && + + nyprompt "Set shutdown timeout for $qube to $value seconds?" || unset value;; + + template) + + if qvm-check -q --running "$qube"; then + + echo Go back... | dmenu-unlinked -p "$qube needs to be powered off, in order to change its template." > /dev/null 2>&1 + else + get_list template + + value=$(printf "(Default)\n$list" | dmenu-unlinked -l 50 -p "Select template for $qube:") && + + (sleep 2 && qvm-appmenus -q --update "$qube"&) + fi;; + + template_for_dispvms) + + value=$(printf 'False\nTrue' | dmenu-unlinked -i -p "Should $qube be used as a template for disposable qubes?");; + + vcpus) + + value=$(echo --default | dmenu-unlinked -p "Enter the number of CPU cores that should be made available to $qube:") && + + nyprompt "Set number of CPU cores available to $qube to $value?" || unset value;; + + virt_mode) + + value=$(printf 'PVH\nHVM\nPV' | dmenu-unlinked -i -l 3 -p "Select virtualisation mode for $qube:");; + + *) + esac + + if [ -n "$value" ]; then + + if [ "$value" = '(None)' ]; then value='' + elif [ "$value" = '(Default)' ]; then value=--default + fi + + qvm-prefs "$qube" "$property" "$value" || + + echo Go back... | dmenu-unlinked -p "Error: Failed to set $property to '$value'!" > /dev/null 2>&1 + + unset value + fi + fi +done |