Skip to content

Instantly share code, notes, and snippets.

@meise
Created November 15, 2012 11:52
Show Gist options
  • Save meise/4078263 to your computer and use it in GitHub Desktop.
Save meise/4078263 to your computer and use it in GitHub Desktop.
Running security updates on debian based systems managed with libvirt and accessible via ssh.
#!/bin/sh
# Running security updates on debian based systems managed with libvirt and
# accessible via ssh.
# Tmux, virsh and ssh are needed for this script.
vms=`virsh list --name`
if [ -z "$TMUX" ]; then
echo "Create tmux session before installing updates:"
echo " tmux new"
exit 1
else
echo Update VMs ${vms}.
echo
for vm in $vms; do
tmux new-window -n $vm "ssh $vm '\
aptitude update && \
aptitude safe-upgrade && \
echo && \
echo Updating done && \
sleep 60'"
done
echo "Check tmux tabs for interaction."
fi
exit 0
@towo
Copy link

towo commented Nov 16, 2012

If you don't want to bother checking if the upgrades are good (this has become sort of feasible with apt-key), have a look at unattended-upgrades.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment