qubes_core_netvm 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/sh
  2. #
  3. # chkconfig: 345 90 90
  4. # description: Executes Qubes core scripts at NetVM boot
  5. #
  6. # Source function library.
  7. . /etc/rc.d/init.d/functions
  8. start()
  9. {
  10. if ! [ -x /usr/bin/xenstore-read ] ; then
  11. echo "ERROR: /usr/bin/xenstore-read not found!"
  12. exit 1
  13. fi
  14. type=$(/usr/bin/xenstore-read qubes_vm_type)
  15. if [ "$type" == "NetVM" ]; then
  16. /sbin/service NetworkManager start
  17. fi
  18. echo -n $"Executing Qubes Core scripts NetVM:"
  19. # Setup gateway for all the VMs this netVM is serviceing...
  20. network=$(/usr/bin/xenstore-read qubes_netvm_network 2>/dev/null)
  21. if [ "x$network" != "x" ]; then
  22. gateway=$(/usr/bin/xenstore-read qubes_netvm_gateway)
  23. netmask=$(/usr/bin/xenstore-read qubes_netvm_netmask)
  24. secondary_dns=$(/usr/bin/xenstore-read qubes_netvm_secondary_dns)
  25. modprobe netbk 2> /dev/null || modprobe xen-netback
  26. echo "NS1=$gateway" > /var/run/qubes/qubes_ns
  27. echo "NS2=$secondary_dns" >> /var/run/qubes/qubes_ns
  28. /usr/lib/qubes/qubes_setup_dnat_to_ns
  29. echo "1" > /proc/sys/net/ipv4/ip_forward
  30. fi
  31. success
  32. echo ""
  33. return 0
  34. }
  35. stop()
  36. {
  37. return 0
  38. }
  39. case "$1" in
  40. start)
  41. start
  42. ;;
  43. stop)
  44. stop
  45. ;;
  46. *)
  47. echo $"Usage: $0 {start|stop}"
  48. exit 3
  49. ;;
  50. esac
  51. exit $RETVAL