1#! /bin/sh
2# daemon starter script
3# based on skeleton from Debian GNU/Linux
4# cliechti at gmx.net
5
6PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
7DAEMON=/usr/local/bin/port_publisher.py
8NAME=port_publisher
9DESC="serial port avahi device publisher"
10
11test -f $DAEMON || exit 0
12
13set -e
14
15case "$1" in
16    start)
17        echo -n "Starting $DESC: "
18        $DAEMON --daemon --pidfile /var/run/$NAME.pid
19        echo "$NAME."
20        ;;
21    stop)
22        echo -n "Stopping $DESC: "
23        start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
24        # \     --exec $DAEMON
25        echo "$NAME."
26        ;;
27    restart|force-reload)
28        echo -n "Restarting $DESC: "
29        start-stop-daemon --stop --quiet --pidfile \
30                /var/run/$NAME.pid
31                # --exec $DAEMON
32        sleep 1
33        $DAEMON --daemon --pidfile /var/run/$NAME.pid
34        echo "$NAME."
35        ;;
36    *)
37        N=/etc/init.d/$NAME
38        echo "Usage: $N {start|stop|restart|force-reload}" >&2
39        exit 1
40        ;;
41esac
42
43exit 0
44
45