101 lines
1.7 KiB
Bash
Executable File
101 lines
1.7 KiB
Bash
Executable File
#! /bin/sh
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: dundee
|
|
# Required-Start: $syslog $remote_fs dbus
|
|
# Required-Stop: $syslog $remote_fs dbus
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: Bluetooth DUN daemon
|
|
### END INIT INFO
|
|
|
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
DAEMON=/usr/sbin/dundee
|
|
NAME=dundee
|
|
PIDFILE=/var/run/$NAME.pid
|
|
DESC="Bluetooth DUN daemon"
|
|
|
|
test -x $DAEMON || exit 0
|
|
|
|
#. /lib/lsb/init-functions
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
# allow the admin to set DAEMON_OPTS
|
|
if [ -f /etc/default/dundee ]; then
|
|
. /etc/default/dundee
|
|
fi
|
|
|
|
do_start()
|
|
{
|
|
start-stop-daemon -S -q -b --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- -n
|
|
}
|
|
|
|
do_stop()
|
|
{
|
|
start-stop-daemon -K -q --remove-pidfile --pidfile $PIDFILE
|
|
}
|
|
|
|
checkrc() {
|
|
if [ $? = 0 ]; then
|
|
success
|
|
else
|
|
failure
|
|
fi
|
|
}
|
|
|
|
success()
|
|
{
|
|
echo -e "[ OK ]\r"
|
|
}
|
|
|
|
failure()
|
|
{
|
|
echo -e "[FAILED]\r"
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
#log_daemon_msg "Starting $DESC" "$NAME"
|
|
echo "Starting $DESC: $NAME"
|
|
pid=$( pidofproc -p $PIDFILE $DAEMON )
|
|
if [ -n "$pid" ] ; then
|
|
echo "Already running"
|
|
exit 0
|
|
fi
|
|
do_start
|
|
#log_end_msg $?
|
|
checkrc
|
|
;;
|
|
stop)
|
|
#log_daemon_msg "Stopping $DESC" "$NAME"
|
|
echo "Stopping $DESC: $NAME"
|
|
do_stop
|
|
#log_end_msg $?
|
|
checkrc
|
|
;;
|
|
|
|
restart|force-reload)
|
|
#log_daemon_msg "Restarting $DESC" "$NAME"
|
|
echo "Restarting $DESC: $NAME"
|
|
echo "Stopping $NAME..."
|
|
do_stop
|
|
checkrc
|
|
sleep 1
|
|
echo "Starting $NAME..."
|
|
do_start
|
|
checkrc
|
|
#log_end_msg $?
|
|
;;
|
|
status)
|
|
statusproc $DAEMON
|
|
exit $?
|
|
;;
|
|
*)
|
|
#log_success_msg "Usage: $0 {start|stop|restart|force-reload}"
|
|
echo "Usage: $0 {start|stop|restart|force-reload|status}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|