25 lines
552 B
Bash
25 lines
552 B
Bash
#!/bin/sh
|
|
# vim: set sw=4 ts=4 sts=4 et :
|
|
|
|
if [ ! -r /etc/vm-autostart ]; then
|
|
exit 0
|
|
fi
|
|
|
|
virsh connect || exit
|
|
|
|
while read name args; do
|
|
if [ "${name}" = delay ]; then
|
|
sleep ${args}
|
|
continue
|
|
fi
|
|
if virsh domuuid "${name}" >/dev/null 2>&1; then
|
|
if virsh domid "${name}" | grep -qE '^[0-9]+$'; then
|
|
printf 'Domain %s is already running\n' "${name}"
|
|
else
|
|
virsh start "${name}"
|
|
fi
|
|
else
|
|
printf 'Domain %s does not exist\n' "${name}"
|
|
fi
|
|
done < /etc/vm-autostart
|