Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A script for updating dom0 and TemplateVMs. Can be run as a cron job.
#!/bin/bash
# Set the updatevm.
updatevm=sys-firewall
# Declare arrays of VMs to be updated.
Fedora=(
'fedora-23'
'fedora-23-minimal'
)
Debian=(
'whonix-gw'
'whonix-ws'
)
# Proceed only if the UpdateVM is running.
if qvm-ls $updatevm | grep -q Running; then
echo "Starting update process."
# Download dom0 updates.
echo "Downloading updates for dom0 at $(date -Is) ...";
sudo qubes-dom0-update -y;
sleep 5;
# Download Fedora VM updates.
for vm in ${Fedora[*]}; do
if qvm-ls $vm | grep -q Halted; then
echo "Updating $vm at $(date -Is) ...";
qvm-start --no-guid -q $vm;
sleep 3;
qvm-run -a --nogui -p -u root $vm 'dnf -y --refresh upgrade';
sleep 10;
qvm-shutdown -q --wait $vm;
sleep 3;
fi
done
#Download Debian VM updates.
for vm in ${Debian[*]}; do
if qvm-ls $vm | grep -q Halted; then
echo "Updating $vm at $(date -Is) ...";
qvm-start --no-guid -q $vm;
sleep 3;
qvm-run -a --nogui -p -u root $vm 'apt-get -y update && apt-get -y dist-upgrade';
sleep 10;
qvm-shutdown -q --wait $vm;
sleep 3;
fi
done
echo "Finished update process at $(date -Is).";
fi
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment