qubes_core_netvm 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. /usr/lib/qubes/network-manager-prepare-conf-dir
  17. /sbin/service NetworkManager start
  18. fi
  19. echo -n $"Executing Qubes Core scripts NetVM:"
  20. # Setup gateway for all the VMs this netVM is serviceing...
  21. network=$(/usr/bin/xenstore-read qubes_netvm_network 2>/dev/null)
  22. if [ "x$network" != "x" ]; then
  23. gateway=$(/usr/bin/xenstore-read qubes_netvm_gateway)
  24. netmask=$(/usr/bin/xenstore-read qubes_netvm_netmask)
  25. secondary_dns=$(/usr/bin/xenstore-read qubes_netvm_secondary_dns)
  26. modprobe netbk 2> /dev/null || modprobe xen-netback
  27. echo "NS1=$gateway" > /var/run/qubes/qubes_ns
  28. echo "NS2=$secondary_dns" >> /var/run/qubes/qubes_ns
  29. /usr/lib/qubes/qubes_setup_dnat_to_ns
  30. echo "1" > /proc/sys/net/ipv4/ip_forward
  31. fi
  32. success
  33. echo ""
  34. return 0
  35. }
  36. stop()
  37. {
  38. return 0
  39. }
  40. case "$1" in
  41. start)
  42. start
  43. ;;
  44. stop)
  45. stop
  46. ;;
  47. *)
  48. echo $"Usage: $0 {start|stop}"
  49. exit 3
  50. ;;
  51. esac
  52. exit $RETVAL