To make Qubes a viable workstation, I’m going to have to streamline a good many operations. Too much friction as is out of the box.
Anyone who’s streamlined their system, save me some hassles. Do you know how each or any of these are done using a bash script?
- Attach a USB device to a VM.
- Check that VM is running. If not start VM.
- Stop a VM.
- Stop all running VMs.
- Launch an app in a VM.
- Run a specific script in a VM.
- Run a script on startup in Dom0, that calls scripts in VMs.
- Attach a script in Dom0 to a hotkey.
- Pass root privileges to a script in Dom0, and attach script to a hotkey.
Any help would be appreciated.
Not sure if your question is more about writing a script or how to execute those commands.
To shut down all VMs, the dom0 command is:
Starting a VM:
(if the VM is already started it just returns "domain is already running)
To stop a VM:
Attaching a USB to a VM or launching a specific application are also just single line commands, but I’m not sure how to link a custom script to a hotkey.
Linking a script to a menu item:
Another approach to executing commands with hotkeys:
Big thanks. Still trying to get scripts to work…
Here’s a skeleton of the startup script I’m trying to get working. I’m not sure exactly how to assign attached drives to a variable. Nor get the scripts the startup script is calling to run with root privileges. Still kinda lost with bash. Anyone who has some pointers, I’d appreciate it.
# startup sequence. Execute on login or hotkey trigger.
# Guard clause
# Execute script only if USB "startup" is plugged in.
# if USB startup not attached, kill
# Assign all block devices to var.
# If USB_startup not in var, kill.
if [[ $attached_drives =~ "USB_startup" ]]; then
# start core VMs (preferable on seperate threads, to spead startup time)
# start the vault VM, and attached USB_startup
qvm-start vault --skip-if-running --quiet --drive=USB_startup
# attached data disk to work vm
qvm-start work --skip-if-running --quiet --hddisk=SSD1
qvm-start web --skip-if-running --quiet
# Initialize security layer (preferable on seperate thread)
# Unlock and mount lucks encrypted drive in VM vault
qvm-run --quiet vault udisksctl unlock -b /path/to/disk/partition
qvm-run --quiet vault udisksctl mount -b /path/to/unlocked/device
# Run startup script with root privileges
qvm-run vault --quiet sudo ./s_startup.sh &
# Initialize work layer (on seperate thread)
qvm-run work --quiet sudo ./s_work.sh &
# Initialize web layer
qvm-run web --quiet sudo ./s_web.sh
I think if root owns the startup script then everything it runs would also be root’s. Not sure what throwing sudo in there otherwise would do.