qubes-iptables 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. #
  3. # qubes-iptables Start Qubes base iptables firewall
  4. #
  5. # chkconfig: 2345 08 92
  6. # description: Loads iptables firewall
  7. #
  8. # config: /etc/qubes/iptables.rules
  9. # config: /etc/qubes/ip6tables.rules
  10. #
  11. ### BEGIN INIT INFO
  12. # Provides: iptables
  13. # Required-Start:
  14. # Required-Stop:
  15. # Default-Start: 2 3 4 5
  16. # Default-Stop: 0 1 6
  17. # Short-Description: Loads Qubes base iptables firewall
  18. # Description: Loads Qubes base iptables firewall
  19. ### END INIT INFO
  20. IPTABLES=iptables
  21. IPTABLES_DATA_DIR=/etc/qubes
  22. if [ ! -x /sbin/$IPTABLES ]; then
  23. echo $"${IPTABLES}: /sbin/$IPTABLES does not exist."
  24. exit 5
  25. fi
  26. start() {
  27. ipt=$1
  28. IPTABLES_DATA=$IPTABLES_DATA_DIR/${ipt}.rules
  29. CMD=$ipt
  30. # Do not start if there is no config file.
  31. [ ! -f "$IPTABLES_DATA" ] && return 6
  32. echo -n $"${CMD}: Applying firewall rules: "
  33. $CMD-restore $IPTABLES_DATA
  34. if [ $? -eq 0 ]; then
  35. echo OK
  36. else
  37. echo FAIL; return 1
  38. fi
  39. return $ret
  40. }
  41. case "$1" in
  42. start)
  43. start iptables && start ip6tables
  44. RETVAL=$?
  45. ;;
  46. *)
  47. echo $"Usage: ${IPTABLES} start"
  48. RETVAL=2
  49. ;;
  50. esac
  51. exit $RETVAL