qubes-core-netvm 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  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/qubesdb-read ] ; then
  11. echo "ERROR: /usr/bin/qubesdb-read not found!"
  12. exit 1
  13. fi
  14. type=$(/usr/bin/qubesdb-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/qubesdb-read /qubes-netvm-network 2>/dev/null)
  22. if [ "x$network" != "x" ]; then
  23. gateway=$(/usr/bin/qubesdb-read /qubes-netvm-gateway)
  24. netmask=$(/usr/bin/qubesdb-read /qubes-netvm-netmask)
  25. secondary_dns=$(/usr/bin/qubesdb-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