qubes-iptables 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. ret="$?"
  35. if [ "$ret" -eq 0 ]; then
  36. echo OK
  37. else
  38. echo FAIL; return 1
  39. fi
  40. return $ret
  41. }
  42. case "$1" in
  43. start)
  44. start iptables && start ip6tables
  45. RETVAL=$?
  46. ;;
  47. *)
  48. echo $"Usage: ${IPTABLES} start"
  49. RETVAL=2
  50. ;;
  51. esac
  52. exit $RETVAL