- #!/bin/sh
- ### BEGIN INIT INFO
- # Provides: trafficctrl
- # Required-Start: $local_fs
- # Required-Stop: $local_fs
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Control categories of network traffic
- # Description: This service provides an HTTP or FastCGI service to
- # provide a control panel for classifying web traffic.
- # It does not take any action by itself.
- #
- # NOTE: you need to use trafficmon to setup the DB first.
- ### END INIT INFO
-
- NAME="trafficctrl"
- DAEMON="/usr/sbin/$NAME"
- RUN=/run
- CONF=""
- PID=""
- GROUP=""
-
- # Pull in config
- if [ -r "/etc/default/$NAME" ]; then
- . /etc/default/$NAME
- fi
-
-
-
- ### Setup control variables ###
-
- # This is where we put PID files and the pipe
- RUN="$RUN/poorman-ids"
- # NOTE: this needs to match what $CONF says
- [ -n "$PID" ] || PID="$RUN/$NAME.pid"
- mkdir -p "$RUN"
- [ -z "$GROUP" ] || GROUP="-g $GROUP"
-
-
-
- ### ACTIONS ###
-
- # The main service command
- CTRL() {
- start-stop-daemon --pidfile "$PID" --exec "$DAEMON" "$@"
- }
-
-
-
- do_start() {
- echo -n "Starting Traffic Control: "
- if [ -z "$CONF" ]; then
- echo "NOT CONFIGURED"
- return 0
- fi
- if CTRL --start --oknodo --umask 007 $GROUP -- -c "$CONF"; then
- echo "OK"
- return 0 #JIC
- else
- echo "FAIL"
- return 1
- fi
- }
-
-
-
- do_stop() {
- echo -n "Stoping Traffic Control: "
- if CTRL --stop --remove-pidfile; then
- echo "OK"
- return 0 #JIC
- else
- echo "FAIL"
- return 1
- fi
- }
-
-
-
- do_status() {
- echo -n "Traffic Control is: "
- if CTRL --status; then
- echo "Up"
- return 0 #JIC
- else
- echo "Down"
- return 1
- fi
- }
-
-
-
- ### Main()
-
- case "$1" in
- start)
- do_start
- ;;
-
- stop)
- do_stop
- ;;
-
- restart)
- do_status && do_stop
- do_start
- ;;
-
- status)
- do_status
- ;;
-
- *)
- echo "$0 {start | stop | restart | status}"
- ;;
-
- esac
|