#!/bin/sh ### BEGIN INIT INFO # Provides: ufw # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: S # Default-Stop: 1 # Short-Description: start firewall ### END INIT INFO set -e setglobal PATH = '"/sbin:/bin'" test -d /lib/ufw || exit 0 source /lib/lsb/init-functions for s in ["/lib/ufw/ufw-init-functions" "/etc/ufw/ufw.conf" "/etc/default/ufw]" { if test -s $s { source "$s" } else { log_failure_msg "Could not find $s (aborting)" exit 1 } } setglobal error = '0' match $1 { with start if test $ENABLED = "yes" || test $ENABLED = "YES" { log_action_begin_msg "Starting firewall:" "ufw" setglobal output = $[ufw_start] || setglobal error = "$Status" if test $error = "0" { log_action_cont_msg "Setting kernel variables ($IPT_SYSCTL)" } if test ! -z $output { echo $output | while read line { log_action_cont_msg $line } } } else { log_action_begin_msg "Skip starting firewall:" "ufw (not enabled)" } log_action_end_msg $error exit $error with stop if test $ENABLED = "yes" || test $ENABLED = "YES" { log_action_begin_msg "Stopping firewall:" "ufw" setglobal output = $[ufw_stop] || setglobal error = "$Status" if test ! -z $output { log_action_cont_msg $output } } else { log_action_begin_msg "Skip stopping firewall:" "ufw (not enabled)" } log_action_end_msg $error exit $error with restart|force-reload log_action_begin_msg "Reloading firewall:" "ufw" setglobal output = $[ufw_reload] || setglobal error = "$Status" if test ! -z $output { log_action_cont_msg $output } log_action_end_msg $error exit $error with status setglobal output = $[ufw_status] || setglobal error = "$Status" if test ! -z $output { log_action_cont_msg $output } log_action_end_msg $error exit $error with * echo "Usage: /etc/init.d/ufw {start|stop|restart|force-reload|status}" exit 1 } exit 0