#!/bin/sh # the following is the LSB init header # ### BEGIN INIT INFO # Provides: prov-guests # Required-Start: libvirtd # Required-Stop: libvirtd # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: resume prov guests on boot # Description: This is a script for resuming prov guests on boot ### END INIT INFO # the following is chkconfig init header # # prov-guests: resume prov guests on boot # # chkconfig: 345 99 01 # description: This is a script for resuming prov guests on boot # RETVAL=0 is_guest_running() { virsh list | grep -q ${1} } start() { if [ ! -d /xen/autostart ] ; then echo "No guests to start; /xen/autostart is missing." exit 1 fi for guest in /xen/autostart/*.cfg ; do file=${guest##*/} uniq_id=${file%%.*} if ! is_guest_running ${uniq_id} ; then virsh create "${guest}" || RETVAL=1 fi done } usage() { echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" } # See how we were called. if test $# != 1; then usage RETVAL=2 else case "$1" in --help) usage ;; condrestart|try-restart|restart|start) start ;; reload|force-reload) # Nothing to do; we have no config ;; status) echo "Use virsh to see the status of running guests." ;; stop) echo "Use virsh or libvirt-guests to stop guests on this host." ;; *) usage RETVAL=2 ;; esac fi exit $RETVAL