~ubuntu-branches/ubuntu/trusty/forked-daapd/trusty-proposed

« back to all changes in this revision

Viewing changes to debian/forked-daapd.init

  • Committer: Bazaar Package Importer
  • Author(s): Julien BLACHE
  • Date: 2010-07-03 11:26:12 UTC
  • Revision ID: james.westby@ubuntu.com-20100703112612-xopisp2hpbonx0h7
Tags: 0.12~git0.11-80-g65d3651-1
* Git snapshot 0.11-80-g65d3651.

* Initial upload (closes: #587958).
  + Upload to experimental until antlr3 can move to testing.

* Moved to source version 3.0 (quilt).

* debian/control:
  + Add Build-dep on libunistring-dev.
  + Bump antlr3 build-dep to (>= 3.2-3).
  + Bump libantlr3c-dev build-dep to (>= 3.2).
  + Bump Standards-Version to 3.9.0 (no changes).
  + Rework descriptions.
* debian/copyright:
  + Updated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
### BEGIN INIT INFO
 
4
# Provides:          forked-daapd
 
5
# Required-Start:    $local_fs $remote_fs $network $time avahi
 
6
# Required-Stop:     $local_fs $remote_fs $network $time
 
7
# Default-Start:     2 3 4 5
 
8
# Default-Stop:      0 1 6
 
9
# Short-Description: media server with support for RSP, DAAP, DACP and AirTunes
 
10
# Description:       forked-daapd is an iTunes-compatible media server for
 
11
#                    sharing your music library over the local network with RSP
 
12
#                    clients like the SoundBridge from Roku and DAAP clients like
 
13
#                    iTunes. It can also stream music to AirTunes devices.
 
14
### END INIT INFO
 
15
 
 
16
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
17
DAEMON=/usr/sbin/forked-daapd
 
18
NAME=forked-daapd
 
19
DESC="RSP and DAAP media server"
 
20
 
 
21
test -x $DAEMON || exit 0
 
22
 
 
23
PIDFILE=/var/run/$NAME.pid
 
24
 
 
25
set -e
 
26
 
 
27
running_pid()
 
28
{
 
29
    # Check if a given process pid's cmdline matches a given name
 
30
    pid=$1
 
31
    name=$2
 
32
    [ -z "$pid" ] && return 1
 
33
    [ ! -d /proc/$pid ] &&  return 1
 
34
    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
 
35
    # Is this the expected child?
 
36
    [ "$cmd" != "$name" ] &&  return 1
 
37
    return 0
 
38
}
 
39
 
 
40
running()
 
41
{
 
42
# Check if the process is running looking at /proc
 
43
# (works for all users)
 
44
 
 
45
    # No pidfile, probably no daemon present
 
46
    [ ! -f "$PIDFILE" ] && return 1
 
47
    # Obtain the pid and check it against the binary name
 
48
    pid=`cat $PIDFILE`
 
49
    running_pid $pid $DAEMON || return 1
 
50
    return 0
 
51
}
 
52
 
 
53
force_stop() {
 
54
# Forcefully kill the process
 
55
    [ ! -f "$PIDFILE" ] && return
 
56
    if running ; then
 
57
        kill -15 $pid
 
58
        # Is it really dead?
 
59
        if running ; then
 
60
            kill -9 $pid
 
61
            if running ; then
 
62
                echo "Cannot kill $NAME (pid=$pid)!"
 
63
                exit 1
 
64
            fi
 
65
        fi
 
66
    fi
 
67
    rm -f $PIDFILE
 
68
    return 0
 
69
}
 
70
 
 
71
case "$1" in
 
72
  start)
 
73
        echo -n "Starting $DESC: "
 
74
        start-stop-daemon --start --quiet --pidfile $PIDFILE \
 
75
            --exec $DAEMON -- $DAEMON_OPTS
 
76
        if running ; then
 
77
            echo "$NAME."
 
78
        else
 
79
            echo " ERROR."
 
80
        fi
 
81
        ;;
 
82
  stop)
 
83
        echo -n "Stopping $DESC: "
 
84
        start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
 
85
            --exec $DAEMON
 
86
        echo "$NAME."
 
87
        ;;
 
88
  force-reload)
 
89
        start-stop-daemon --stop --test --quiet --pidfile \
 
90
            /var/run/$NAME.pid --exec $DAEMON \
 
91
            && $0 restart \
 
92
            || exit 0
 
93
        ;;
 
94
  restart)
 
95
    echo -n "Restarting $DESC: "
 
96
        start-stop-daemon --stop --quiet --pidfile \
 
97
            /var/run/$NAME.pid --exec $DAEMON
 
98
        start-stop-daemon --start --quiet --pidfile \
 
99
            /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
 
100
        echo "$NAME."
 
101
        ;;
 
102
  status)
 
103
    echo -n "$NAME is "
 
104
    if running ;  then
 
105
        echo "running"
 
106
    else
 
107
        echo " not running."
 
108
        exit 1
 
109
    fi
 
110
    ;;
 
111
  *)
 
112
    N=/etc/init.d/$NAME
 
113
    echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
 
114
    exit 1
 
115
    ;;
 
116
esac
 
117
 
 
118
exit 0