4 # Required-Start: $local_fs $remote_fs
5 # Required-Stop: $local_fs $remote_fs
6 # Default-Start: 2 3 4 5
8 # Short-Description: Start port forwarding server
9 # Description: This file should be used to construct scripts to be
10 # placed in /etc/init.d.
13 # Author: Mark Wooding <mdw@distorted.org.uk>
17 # PATH should only include /usr/* if it runs after the mountnfs.sh script
18 PATH=/sbin:/usr/sbin:/bin:/usr/bin
19 DESC="port forwarding daemon"
22 PIDFILE=/var/run/$NAME.pid
23 SCRIPTNAME=/etc/init.d/$NAME
24 FWUSER=fwd FWGROUP=fwd
25 DAEMON_ARGS="--syslog"
27 OLDCONFIG=/etc/fw.conf
29 # Exit if the package is not installed
30 [ -x "$DAEMON" ] || exit 0
32 # Read configuration variable file if it is present
33 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
35 # Exit if no configuration file
36 if [ -r "$CONFIG" ] && [ -r "$OLDCONFIG" ]; then
38 "Using old config file /etc/fw.conf. Please rename it to /etc/fwd.conf."
41 [ -r "$CONFIG" ] || exit 0
43 # Load the VERBOSE setting and other rcS variables
46 # Define LSB log_* functions.
47 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
48 . /lib/lsb/init-functions
51 # Function that starts the daemon/service
56 # 0 if daemon has been started
57 # 1 if daemon was already running
58 # 2 if daemon could not be started
59 start-stop-daemon --start --quiet --pidfile $PIDFILE \
60 --exec $DAEMON --test > /dev/null \
62 start-stop-daemon --start --quiet --pidfile $PIDFILE \
64 --pidfile="$PIDFILE" \
67 --setuid="$FWUSER" --setgid="$FWGROUP" \
73 # Function that stops the daemon/service
78 # 0 if daemon has been stopped
79 # 1 if daemon was already stopped
80 # 2 if daemon could not be stopped
81 # other if a failure occurred
82 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
83 --pidfile "$PIDFILE" --name $NAME
85 [ "$RETVAL" = 2 ] && return 2
91 # Function that sends a SIGHUP to the daemon/service
95 # If the daemon can reload its configuration without
96 # restarting (for example, when it is sent a SIGHUP),
97 # then implement that here.
99 start-stop-daemon --stop --signal 1 --quiet --pidfile "$PIDFILE" \
106 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
109 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
110 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
114 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
117 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
118 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
122 log_daemon_msg "Reloading $DESC" "$NAME"
127 log_daemon_msg "Restarting $DESC" "$NAME"
134 1) log_end_msg 1 ;; # Old process is still running
135 *) log_end_msg 1 ;; # Failed to start
145 echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2