desktop/ufw/ufw.rc

65 lines
1.1 KiB
Bash

#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
[ -x /usr/bin/ufw ] || exit 0
for s in "/lib/ufw/ufw-init-functions" "/etc/ufw/ufw.conf" ; do
if [ -s "$s" ]; then
. "$s"
else
echo "Could not find $s (aborting)"
exit 1
fi
done
error=0
case "$1" in
start)
if [ "$ENABLED" = "yes" ] || [ "$ENABLED" = "YES" ]; then
stat_busy "Starting ufw"
if ! ufw_start; then
stat_fail
else
add_daemon ufw
stat_done
fi
else
echo "Skip starting firewall:" "ufw (not enabled)"
fi
;;
stop)
if [ "$ENABLED" = "yes" ] || [ "$ENABLED" = "YES" ]; then
stat_busy "Stopping ufw"
if ! ufw_stop; then
stat_fail
else
rm_daemon ufw
stat_done
fi
else
echo "Skip stopping firewall:" "ufw (not enabled)"
fi
;;
restart|force-reload)
stat_busy "Reloading ufw"
if ! ufw_reload; then
stat_fail
else
stat_done
fi
;;
status)
ufw_status
;;
*)
echo "Usage: /etc/rc.d/ufw {start|stop|restart|force-reload|status}"
exit 1
;;
esac
exit 0