qubes_netvm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. #
  3. # chkconfig: 2345 99 00
  4. # description: Starts/stops Qubes default netvm
  5. #
  6. ### BEGIN INIT INFO
  7. # Provides: qubes-networking
  8. # Required-Start: qubes-core
  9. # Default-Start: 3 4 5
  10. # Default-Stop: 0 1 2 6
  11. # Default-Enabled: yes
  12. # Short-Description: Start/stop qubes networking
  13. # Description: Starts and stops the qubes networking
  14. ### END INIT INFO
  15. #
  16. # Source function library.
  17. . /etc/rc.d/init.d/functions
  18. NETVM=$(qvm-get-default-netvm)
  19. start()
  20. {
  21. if [ x$NETVM = x ] ; then
  22. echo WARNING: Qubes NetVM not configured!
  23. echo -n $"Doing nothing:"
  24. elif [ $NETVM = "dom0" ] ; then
  25. echo -n $"Setting up net backend in Dom0:"
  26. echo "NS1=10.0.0.1" > /var/run/qubes/qubes_ns
  27. echo "NS2=10.0.255.254" >> /var/run/qubes/qubes_ns
  28. /usr/lib/qubes/qubes_setup_dnat_to_ns
  29. echo "1" > /proc/sys/net/ipv4/ip_forward || exit 1
  30. else
  31. echo -n $"Starting default NetVM:"
  32. /usr/lib/qubes/unbind_all_network_devices || exit 1
  33. qvm-start -q --no-guid $NETVM || exit 1
  34. fi
  35. touch /var/lock/subsys/qubes_netvm
  36. success
  37. echo
  38. return 0
  39. }
  40. stop()
  41. {
  42. if [ x$NETVM = x ] ; then
  43. echo WARNING: Qubes NetVM not configured!
  44. echo -n $"Doing nothing:"
  45. elif [ $NETVM = "dom0" ] ; then
  46. echo -n $"Stopping Qubes networking in Dom0:"
  47. else
  48. echo -n $"Stopping default NetVM:"
  49. qvm-run -q --shutdown --wait $NETVM
  50. fi
  51. rm -f /var/lock/subsys/qubes_netvm
  52. success
  53. echo
  54. return 0
  55. }
  56. case "$1" in
  57. start)
  58. start
  59. ;;
  60. stop)
  61. stop
  62. ;;
  63. *)
  64. echo $"Usage: $0 {start|stop}"
  65. exit 3
  66. ;;
  67. esac
  68. exit $RETVAL