~george-edison55/audataserver-proxy/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash

### BEGIN INIT INFO
# Provides:          audataserver-proxy
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the AU Data Server during boot
# Description:       Starts the Ask Ubuntu Data server when the computer boots
### END INIT INFO

# A few definitions:
APPNAME="Ask Ubuntu Data Server"
APPPATH="/usr/bin"
APPCOMMAND="audataserver-proxy"
PIDFILE="/var/run/audataserver-proxy.pid"

# Use the init.d utility library
. /lib/lsb/init-functions

start_server() {
    start-stop-daemon -S -q -b --exec $APPPATH/$APPCOMMAND -- --pid-file $PIDFILE
}

stop_server() {
    start-stop-daemon -K -q -p $PIDFILE
}

status_server() {
    if [ -f $PIDFILE ] ; then
        return 0
    else
        return 1
    fi
}

case "$1" in
    start)
        log_action_begin_msg "Starting $APPNAME: $APPCOMMAND."
        start_server
        log_action_end_msg $?
        ;;
    stop)
        log_action_begin_msg "Stopping $APPNAME: $APPCOMMAND."
        stop_server
        log_action_end_msg $?
        exit $?
        ;;
    restart)
        log_action_begin_msg "Restarting $APPNAME: $APPCOMMAND."
        stop_server
        start_server
        log_action_end_msg $?
        ;;
    force-reload)
        ;;
    status)
        status_server
        exit $?
        ;;
    *)
        echo "Usage: /etc/init.d/$APPCOMMAND {start|stop|restart|force-reload|status}"
        exit 1
        ;;
esac