~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to utopic/etc/init.d/mythexport

  • 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
 
 
3
 
### BEGIN INIT INFO
4
 
# Provides:          mythexport 
5
 
# Required-Start:    $local_fs $remote_fs $network
6
 
# Required-Stop:     $local_fs
7
 
# Default-Start:     2 3 4 5
8
 
# Default-Stop:      0 1 6
9
 
# Short-Description: Start/Stop the MythExport Daemon.
10
 
### END INIT INFO
11
 
 
12
 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
13
 
DAEMON=/usr/bin/mythexport-daemon
14
 
NAME="mythexport"
15
 
COMMAND=/usr/bin/perl
16
 
ARGS=""
17
 
DESC="MythExport Daemon"
18
 
 
19
 
test -x $DAEMON || exit 0
20
 
 
21
 
. /lib/lsb/init-functions
22
 
 
23
 
set -e
24
 
 
25
 
USER=mythtv
26
 
USER_HOME=$(grep ^$USER /etc/passwd | awk -F : '{print $6}')
27
 
RUNDIR=/var/run/mythtv
28
 
NICE=0
29
 
 
30
 
mkdir -p $RUNDIR
31
 
chown -R $USER $RUNDIR
32
 
 
33
 
unset DISPLAY
34
 
unset SESSION_MANAGER
35
 
 
36
 
case "$1" in
37
 
  start)
38
 
        if [ -e $RUNDIR/$NAME.pid ]; then
39
 
                PIDDIR=/proc/$(cat $RUNDIR/$NAME.pid)
40
 
                if [ -d ${RUNDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${COMMAND}" ]; then
41
 
                        log_success_msg "$DESC already started; use restart instead."
42
 
                        exit 0
43
 
                else
44
 
                        log_success_msg "Removing stale PID file $RUNDIR/$NAME"
45
 
                        rm -f $RUNDIR/$NAME.pid
46
 
                fi
47
 
        fi
48
 
        log_daemon_msg "Starting $DESC: $NAME "
49
 
        start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
50
 
                --chuid $USER --nicelevel $NICE --exec $COMMAND --startas $DAEMON $ARGS
51
 
        log_end_msg $?
52
 
        ;;
53
 
  stop)
54
 
        log_daemon_msg "Stopping $DESC: $NAME "
55
 
        start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \
56
 
                --chuid $USER --exec $COMMAND --startas $DAEMON $ARGS
57
 
        log_end_msg $?
58
 
        test -e $RUNDIR/$NAME.pid && rm $RUNDIR/$NAME.pid
59
 
        ;;
60
 
  restart|force-reload)
61
 
        log_daemon_msg "Restarting $DESC: $NAME "
62
 
        start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \
63
 
                --chuid $USER --exec $COMMAND --startas $DAEMON $ARGS
64
 
        sleep 3
65
 
        start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
66
 
                --chuid $USER --nicelevel $NICE --exec $COMMAND --startas $DAEMON $ARGS
67
 
    log_end_msg $?
68
 
        ;;
69
 
  status)
70
 
        # We want to maintain backward compatibility with Hardy,
71
 
        # so we're not going to use status_of_proc()
72
 
        pidofproc -p $RUNDIR/$NAME.pid $DAEMON >/dev/null && status=0 || status=$?
73
 
        if [ $status -eq 0 ]; then
74
 
                log_success_msg "$NAME is running"
75
 
        else
76
 
                log_failure_msg "$NAME is not running"
77
 
        fi
78
 
        exit $status
79
 
        ;;
80
 
  *)
81
 
        N=/etc/init.d/$NAME
82
 
        echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
83
 
        exit 2
84
 
        ;;
85
 
esac
86
 
 
87
 
exit 0