2015-02-05 03:14:41 +01:00
|
|
|
#!/bin/bash
|
2011-03-11 01:38:04 +01:00
|
|
|
#
|
|
|
|
# chkconfig: 345 90 90
|
|
|
|
# description: Executes Qubes core scripts at NetVM boot
|
|
|
|
#
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
2013-06-07 05:20:55 +02:00
|
|
|
if ! [ -x /usr/bin/qubesdb-read ] ; then
|
|
|
|
echo "ERROR: /usr/bin/qubesdb-read not found!"
|
2011-03-11 01:38:04 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-06-07 05:20:55 +02:00
|
|
|
type=$(/usr/bin/qubesdb-read /qubes-vm-type)
|
2011-03-11 01:38:04 +01:00
|
|
|
if [ "$type" == "NetVM" ]; then
|
2012-01-30 14:20:02 +01:00
|
|
|
/usr/lib/qubes/network-manager-prepare-conf-dir
|
2011-03-11 01:38:04 +01:00
|
|
|
/sbin/service NetworkManager start
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -n $"Executing Qubes Core scripts NetVM:"
|
|
|
|
|
|
|
|
# Setup gateway for all the VMs this netVM is serviceing...
|
2013-06-07 05:20:55 +02:00
|
|
|
network=$(/usr/bin/qubesdb-read /qubes-netvm-network 2>/dev/null)
|
2011-03-11 01:38:04 +01:00
|
|
|
if [ "x$network" != "x" ]; then
|
2013-06-07 05:20:55 +02:00
|
|
|
gateway=$(/usr/bin/qubesdb-read /qubes-netvm-gateway)
|
|
|
|
netmask=$(/usr/bin/qubesdb-read /qubes-netvm-netmask)
|
|
|
|
secondary_dns=$(/usr/bin/qubesdb-read /qubes-netvm-secondary-dns)
|
2011-09-08 01:06:39 +02:00
|
|
|
modprobe netbk 2> /dev/null || modprobe xen-netback
|
2013-03-13 02:26:40 +01:00
|
|
|
echo "NS1=$gateway" > /var/run/qubes/qubes-ns
|
|
|
|
echo "NS2=$secondary_dns" >> /var/run/qubes/qubes-ns
|
|
|
|
/usr/lib/qubes/qubes-setup-dnat-to-ns
|
2011-03-11 01:38:04 +01:00
|
|
|
echo "1" > /proc/sys/net/ipv4/ip_forward
|
|
|
|
fi
|
2011-03-21 13:54:35 +01:00
|
|
|
|
2011-03-11 01:38:04 +01:00
|
|
|
success
|
|
|
|
echo ""
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $0 {start|stop}"
|
|
|
|
exit 3
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|