68 lines
1.5 KiB
Bash
Executable File
68 lines
1.5 KiB
Bash
Executable File
#!/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 FirewallVM:"
|
|
|
|
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...
|
|
modprobe netbk
|
|
gateway=$(/usr/bin/xenstore-read qubes_netvm_gateway)
|
|
netmask=$(/usr/bin/xenstore-read qubes_netvm_netmask)
|
|
network=$(/usr/bin/xenstore-read qubes_netvm_network)
|
|
secondary_dns=$(/usr/bin/xenstore-read qubes_netvm_secondary_dns)
|
|
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
|
|
echo "1" > /proc/sys/net/ipv4/ip_forward
|
|
|
|
# Now setup "AppVM" part of FirewallVM
|
|
ip=$(/usr/bin/xenstore-read qubes_ip)
|
|
netmask=$(/usr/bin/xenstore-read qubes_netmask)
|
|
gateway=$(/usr/bin/xenstore-read qubes_gateway)
|
|
secondary_dns=$(/usr/bin/xenstore-read qubes_secondary_dns)
|
|
if [ x$ip != x ]; then
|
|
/sbin/ifconfig eth0 $ip netmask 255.255.255.255 up
|
|
/sbin/route add default dev eth0
|
|
echo "nameserver $gateway" > /etc/resolv.conf
|
|
echo "nameserver $secondary_dns" >> /etc/resolv.conf
|
|
fi
|
|
|
|
success
|
|
echo ""
|
|
return 0
|
|
}
|
|
|
|
stop()
|
|
{
|
|
return 0
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
*)
|
|
echo $"Usage: $0 {start|stop}"
|
|
exit 3
|
|
;;
|
|
esac
|
|
|
|
exit $RETVAL
|