qubes-core-netvm 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. primary_dns=$(/usr/bin/qubesdb-read /qubes-netvm-primary-dns || echo $gateway)
  26. secondary_dns=$(/usr/bin/qubesdb-read /qubes-netvm-secondary-dns)
  27. modprobe netbk 2> /dev/null || modprobe xen-netback
  28. echo "NS1=$primary_dns" > /var/run/qubes/qubes-ns
  29. echo "NS2=$secondary_dns" >> /var/run/qubes/qubes-ns
  30. /usr/lib/qubes/qubes-setup-dnat-to-ns
  31. echo "1" > /proc/sys/net/ipv4/ip_forward
  32. fi
  33. success
  34. echo ""
  35. return 0
  36. }
  37. stop()
  38. {
  39. return 0
  40. }
  41. case "$1" in
  42. start)
  43. start
  44. ;;
  45. stop)
  46. stop
  47. ;;
  48. *)
  49. echo $"Usage: $0 {start|stop}"
  50. exit 3
  51. ;;
  52. esac
  53. exit $RETVAL