2010-04-05 20:58:57 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# chkconfig: 345 90 90
|
|
|
|
# description: Executes Qubes core scripts at VM boot
|
|
|
|
#
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
|
|
|
echo -n $"Executing Qubes Core scripts NetVM:"
|
|
|
|
|
|
|
|
if ! [ -x /usr/bin/xenstore-read ] ; then
|
|
|
|
echo "ERROR: /usr/bin/xenstore-read not found!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
name=$(/usr/bin/xenstore-read name)
|
|
|
|
hostname $name
|
|
|
|
|
|
|
|
# Setup gateway for all the VMs this netVM is serviceing...
|
|
|
|
brctl addbr br0
|
|
|
|
gateway=$(/usr/bin/xenstore-read qubes_netvm_gateway)
|
|
|
|
netmask=$(/usr/bin/xenstore-read qubes_netvm_netmask)
|
|
|
|
network=$(/usr/bin/xenstore-read qubes_netvm_network)
|
2010-05-19 16:19:01 +02:00
|
|
|
secondary_dns=$(/usr/bin/xenstore-read qubes_netvm_secondary_dns)
|
2010-04-05 20:58:57 +02:00
|
|
|
ifconfig br0 $gateway netmask $netmask up
|
2010-05-19 16:19:01 +02:00
|
|
|
ifconfig br0:1 $secondary_dns netmask $netmask
|
|
|
|
echo "NS1=$gateway" > /var/run/qubes_ns
|
|
|
|
echo "NS2=$secondary_dns" >> /var/run/qubes_ns
|
|
|
|
qubes_setup_dnat_to_ns
|
2010-04-05 20:58:57 +02:00
|
|
|
echo "1" > /proc/sys/net/ipv4/ip_forward
|
2010-05-19 16:19:01 +02:00
|
|
|
#now no need for dnsmasq
|
|
|
|
# dnsmasq --listen-address $gateway --bind-interfaces
|
2010-04-05 20:58:57 +02:00
|
|
|
#now done by iptables rc script
|
|
|
|
# iptables -t nat -A POSTROUTING -s $network/$netmask -j MASQUERADE
|
2010-05-19 16:19:01 +02:00
|
|
|
#no, we cannot put ip-dependent stuff in sysconfig/iptables
|
2010-06-04 13:28:29 +02:00
|
|
|
#so make it ip-independent
|
2010-04-05 20:58:57 +02: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
|