~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to utopic/etc/init.d/amule-adunanza-daemon

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
### BEGIN INIT INFO
3
 
# Provides:          amule-adunanza-daemon
4
 
# Required-Start:    $local_fs $remote_fs
5
 
# Required-Stop:     $local_fs $remote_fs
6
 
# Should-Start:      $network
7
 
# Should-Stop:       $network
8
 
# Default-Start:     2 3 4 5
9
 
# Default-Stop:      0 1 6
10
 
# Short-Description: Daemonized version of aMule.
11
 
# Description:       Starts the aMule daemon with the user specified in
12
 
#                    /etc/default/amule-adunanza-daemon.
13
 
### END INIT INFO
14
 
 
15
 
PATH=/sbin:/usr/sbin:/bin:/usr/bin
16
 
 
17
 
PROGNAME=amuled
18
 
DESC="aMule AdunanzA daemon"
19
 
PKGNAME="amule-adunanza-daemon"
20
 
DAEMON=/usr/bin/amuled
21
 
SCRIPTNAME=/etc/init.d/$PKGNAME
22
 
WRAPPER=/usr/share/amule/amuled_home_wrapper.sh
23
 
 
24
 
[ -x "$DAEMON" ] || exit 0
25
 
[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME
26
 
 
27
 
. /lib/init/vars.sh # has VERBOSE
28
 
. /lib/lsb/init-functions
29
 
 
30
 
if [ -z "$AMULED_USER" ]; then
31
 
    log_warning_msg \
32
 
        "Not starting $DESC, AMULED_USER not set in /etc/default/$PKGNAME."
33
 
    exit 0
34
 
fi
35
 
 
36
 
do_start()
37
 
{
38
 
        # Return
39
 
        #   0 if daemon has been started
40
 
        #   1 if daemon was already running
41
 
        #   2 if daemon could not be started
42
 
        start-stop-daemon --start --quiet --exec $DAEMON --user "$AMULED_USER" --chuid "$AMULED_USER" --test >/dev/null || return 1
43
 
        start-stop-daemon --start --quiet --exec $WRAPPER --user "$AMULED_USER" --chuid "$AMULED_USER" >/dev/null || return 2
44
 
}
45
 
 
46
 
do_stop()
47
 
{
48
 
        # Return
49
 
        #   0 if daemon has been stopped
50
 
        #   1 if daemon was already stopped
51
 
        #   2 if daemon could not be stopped
52
 
        start-stop-daemon --stop --quiet --retry="TERM/30/KILL/5" --exec $DAEMON --user "$AMULED_USER" --chuid "$AMULED_USER" 
53
 
        return "$?"
54
 
}
55
 
 
56
 
 
57
 
case "$1" in
58
 
  start)
59
 
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$PROGNAME"
60
 
        do_start
61
 
        case "$?" in
62
 
                0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
63
 
                1) [ "$VERBOSE" != no ] && \
64
 
                        log_progress_msg "(already running)" && log_end_msg 0 ;;
65
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1; exit 1 ;;
66
 
        esac
67
 
        ;;
68
 
  stop)
69
 
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$PROGNAME"
70
 
        do_stop
71
 
        case "$?" in
72
 
                0 | 1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
73
 
                2)     [ "$VERBOSE" != no ] && log_end_msg 1; exit 1 ;;
74
 
        esac
75
 
        ;;
76
 
  restart|force-reload)
77
 
        log_daemon_msg "Restarting $DESC" "$PROGNAME"
78
 
        do_stop
79
 
        case "$?" in
80
 
          0 | 1)
81
 
                do_start
82
 
                case "$?" in
83
 
                        0) log_end_msg 0 ;;
84
 
                        1) log_end_msg 1; exit 1 ;; # Old process is still running
85
 
                        *) log_end_msg 1; exit 1 ;; # Failed to start
86
 
                esac
87
 
                ;;
88
 
          *)
89
 
                # Failed to stop
90
 
                log_end_msg 1
91
 
                exit 1
92
 
                ;;
93
 
        esac
94
 
        ;;
95
 
  *)
96
 
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
97
 
        exit 3
98
 
        ;;
99
 
esac
100
 
 
101
 
exit 0