#!/bin/sh
# Log a smiley to syslog.
#
# This is an example firewall script for /etc/firewall.d/.
#
# On start, scripts are run in the same order as they appear in a directory
# listing. A script named "a" would come before "b" but after "00_z". You
# should probably start your script name with a number to make it clear when it
# will run. On stop, scripts are run in the reverse order.
#
# Scripts should handle the following arguments: start, stop, restart,
# force-reload, and status. See
# http://www.debian.org/doc/debian-policy/ch-opersys.html#s-writing-init for
# details.

NAME="30_log_a_smiley"
# This line allows an administrator to replace the values above (just NAME,
# in this example) by putting the same line with a different value in the file
# /etc/default/firewall.d/30_log_a_smiley.
test -f /etc/default/firewall.d/30_log_a_smiley && . /etc/default/firewall.d/30_log_a_smiley

start () {
    # This function should install the required behaviour. It should handle
    # running multiple times, with no call to stop(), without adding multiple
    # copies of the behaviour.
    
    # This line prints the name of the script to give the user information
    # about the progress of the firewall.
    log_progress_msg $NAME
    remove 2> /dev/null # Try to remove functionality, if possible, so that
        # start can be run multiple times in a row.
    echo ":)" | logger
}
stop () {
    log_progress_msg $NAME
    remove
}
remove () {
    # This function should remove the behaviour added by start().
    echo ":)" | logger
}
status () {
    # This should give the user a short summary of the behaviour *currently*
    # installed by this script.
    echo ":)"
}

# You probably shouldn't edit anything below here.
test -f /lib/lsb/init-functions && . /lib/lsb/init-functions

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart|force-reload)
        stop
        start
        ;;
    status)
        status
        exit 0
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|force-reload|status}"
        exit 1
        ;;
esac
