home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / ufw / examples / initscript.example next >
Encoding:
Text File  |  2009-03-18  |  1.4 KB  |  71 lines

  1. #!/bin/sh -e
  2.  
  3. #
  4. # Example initscript for ufw
  5. #
  6.  
  7. PATH="/sbin:/bin:/usr/sbin:/usr/bin"
  8. prefix="/usr"
  9. config_prefix="/etc"
  10.  
  11. [ -x $prefix/sbin/ufw ] || exit 0
  12.  
  13. for s in "$prefix/share/ufw/ufw-init-functions" "$config_prefix/ufw/ufw.conf" ; do
  14.     if [ -s "$s" ]; then
  15.         . "$s"
  16.     else
  17.         echo "Could not find $s (aborting)"
  18.         exit 1
  19.     fi
  20. done
  21.  
  22. error=0
  23. case "$1" in
  24. start)
  25.     if [ "$ENABLED" = "yes" ] || [ "$ENABLED" = "YES" ]; then
  26.         echo "Starting firewall:" "ufw"
  27.         output=`ufw_start` || error="$?"
  28.         if [ ! -z "$output" ]; then
  29.             /bin/echo -e "$output"
  30.         fi
  31.     else
  32.         echo "Skip starting firewall:" "ufw (not enabled)"
  33.     fi
  34.     exit $error
  35.     ;;
  36. stop)
  37.     if [ "$ENABLED" = "yes" ] || [ "$ENABLED" = "YES" ]; then
  38.         echo "Stopping firewall:" "ufw"
  39.         output=`ufw_stop` || error="$?"
  40.         if [ ! -z "$output" ]; then
  41.             /bin/echo -e "$output"
  42.         fi
  43.     else
  44.         echo "Skip stopping firewall:" "ufw (not enabled)"
  45.     fi
  46.     exit $error
  47.     ;;
  48. restart|force-reload)
  49.     echo "Reloading firewall:" "ufw"
  50.     output=`ufw_reload` || error="$?"
  51.     if [ ! -z "$output" ]; then
  52.         /bin/echo -e "$output"
  53.     fi
  54.     exit $error
  55.     ;;
  56. status)
  57.     output=`ufw_status` || error="$?"
  58.     if [ ! -z "$output" ]; then
  59.         /bin/echo -e "$output"
  60.     fi
  61.     exit $error
  62.     ;;
  63. *)
  64.     echo "Usage: /etc/init.d/ufw {start|stop|restart|force-reload|status}"
  65.     exit 1
  66.     ;;
  67. esac
  68.  
  69. exit 0
  70.  
  71.