2010-04-05 20:58:57 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2011-04-05 14:31:19 +02:00
|
|
|
# chkconfig: 2345 81 00
|
2010-04-05 20:58:57 +02:00
|
|
|
# description: Starts/stops Qubes default netvm
|
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: qubes-networking
|
|
|
|
# Required-Start: qubes-core
|
|
|
|
# Default-Start: 3 4 5
|
|
|
|
# Default-Stop: 0 1 2 6
|
|
|
|
# Default-Enabled: yes
|
|
|
|
# Short-Description: Start/stop qubes networking
|
|
|
|
# Description: Starts and stops the qubes networking
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
NETVM=$(qvm-get-default-netvm)
|
|
|
|
|
2011-03-31 01:58:45 +02:00
|
|
|
get_running_netvms() {
|
|
|
|
# Actually get running VMs with PCI devices attached
|
2011-06-01 23:44:06 +02:00
|
|
|
RUNNING_VMS=`xl list | tail -n +3 | cut -f 1 -d " "`
|
2011-03-31 01:58:45 +02:00
|
|
|
RUNNING_NETVMS=""
|
|
|
|
for VM in $RUNNING_VMS; do
|
2011-06-01 23:44:06 +02:00
|
|
|
if [ -n "`xl pci-list $VM`" ]; then
|
2011-03-31 01:58:45 +02:00
|
|
|
echo "$VM"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2010-04-05 20:58:57 +02:00
|
|
|
start()
|
|
|
|
{
|
|
|
|
if [ x$NETVM = x ] ; then
|
|
|
|
|
|
|
|
echo WARNING: Qubes NetVM not configured!
|
|
|
|
echo -n $"Doing nothing:"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo -n $"Starting default NetVM:"
|
2011-07-17 00:56:57 +02:00
|
|
|
DISPLAY=:0 sg qubes "qvm-start -q --no-guid $NETVM" || exit 1
|
2010-04-05 20:58:57 +02:00
|
|
|
|
|
|
|
fi
|
|
|
|
touch /var/lock/subsys/qubes_netvm
|
|
|
|
success
|
|
|
|
echo
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
if [ x$NETVM = x ] ; then
|
|
|
|
|
|
|
|
echo WARNING: Qubes NetVM not configured!
|
|
|
|
echo -n $"Doing nothing:"
|
|
|
|
|
2010-09-06 17:07:42 +02:00
|
|
|
else
|
2010-04-05 20:58:57 +02:00
|
|
|
|
2011-03-31 01:58:45 +02:00
|
|
|
echo -n $"Stopping NetVMs:"
|
|
|
|
for VM in `get_running_netvms`; do
|
|
|
|
qvm-run -q --shutdown --wait $VM
|
|
|
|
done
|
2010-04-05 20:58:57 +02:00
|
|
|
|
|
|
|
fi
|
|
|
|
rm -f /var/lock/subsys/qubes_netvm
|
|
|
|
success
|
|
|
|
echo
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $0 {start|stop}"
|
|
|
|
exit 3
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|