test -f "$sysconfdir"/sysconfig/libvirt-guests && . "$sysconfdir"/sysconfig/libvirt-guests
LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests
+VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests
RETVAL=0
return 0
}
+started() {
+ touch "$VAR_SUBSYS_LIBVIRT_GUESTS"
+}
+
start() {
- [ -f $LISTFILE ] || return 0
+ [ -f "$LISTFILE" ] || { started; return 0; }
if [ "x$ON_BOOT" != xstart ]; then
echo $"libvirt-guests is configured not to start any guests on boot"
- rm -f $LISTFILE
+ rm -f "$LISTFILE"
+ started
return 0
fi
fi
fi
done
- done <$LISTFILE
+ done <"$LISTFILE"
- rm -f $LISTFILE
+ rm -f "$LISTFILE"
+ started
}
suspend_guest()
stop() {
# last stop was not followed by start
- [ -f $LISTFILE ] && return 0
+ [ -f "$LISTFILE" ] && return 0
suspending=true
if [ "x$ON_SHUTDOWN" = xshutdown ]; then
fi
fi
- : >$LISTFILE
+ : >"$LISTFILE"
for uri in $URIS; do
echo -n $"Running guests on $uri URI: "
list=$(list_guests $uri)
echo $"no running guests."
else
echo
- echo $uri $list >>$LISTFILE
+ echo $uri $list >>"$LISTFILE"
fi
fi
done
shutdown_guest $uri $guest
fi
done
- done <$LISTFILE
+ done <"$LISTFILE"
+
+ rm -f "$VAR_SUBSYS_LIBVIRT_GUESTS"
}
gueststatus() {
force-reload)
;;
status)
- if [ -f $LISTFILE ]; then
+ if [ -f "$LISTFILE" ]; then
RETVAL=3
else
RETVAL=0
fi
%endif
-%post client -p /sbin/ldconfig
+%preun client
+
+if [ $1 = 0 ]; then
+ /sbin/chkconfig --del libvirt-guests
+ rm -f /var/lib/libvirt/libvirt-guests
+fi
+
+%post client
+
+/sbin/ldconfig
+/sbin/chkconfig --add libvirt-guests
+if [ $1 -ge 1 ]; then
+ # this doesn't do anything but allowing for libvirt-guests to be
+ # stopped on the first shutdown
+ /sbin/service libvirt-guests start > /dev/null 2>&1 || true
+fi
%postun client -p /sbin/ldconfig