~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to vivid/etc/init.d/ushare

  • 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 -e
 
2
#
 
3
# uShare init script
 
4
#
 
5
### BEGIN INIT INFO
 
6
# Provides:          ushare
 
7
# Required-Start:    $local_fs $syslog $network
 
8
# Should-Start:
 
9
# Required-Stop:
 
10
# Should-Stop:
 
11
# Default-Start:     2 3 4 5
 
12
# Default-Stop:      0 1 6
 
13
# Short-Description: uShare
 
14
# Description:       uShare UPnP (TM) A/V & DLNA Media Server
 
15
#                    You should edit configuration in /etc/ushare.conf file
 
16
#                    See http://ushare.geexbox.org for details
 
17
### END INIT INFO
 
18
 
 
19
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
20
DAEMON=/usr/bin/ushare
 
21
NAME=ushare
 
22
DESC="uShare UPnP A/V & DLNA Media Server"
 
23
PIDFILE=/var/run/ushare.pid
 
24
CONFIGFILE=/etc/ushare.conf
 
25
 
 
26
# abort if no executable exists
 
27
[ -x $DAEMON ] || exit 0
 
28
 
 
29
# Get lsb functions
 
30
. /lib/lsb/init-functions
 
31
. /etc/default/rcS
 
32
 
 
33
[ -f /etc/default/ushare ] && . /etc/default/ushare
 
34
 
 
35
checkpid() {
 
36
  [ -e $PIDFILE ] || touch $PIDFILE
 
37
}
 
38
 
 
39
check_shares() {
 
40
  if [ -r "$CONFIGFILE" ]; then
 
41
    . $CONFIGFILE
 
42
    [ -n "$USHARE_DIR" ] && return 0
 
43
  fi
 
44
  return 1
 
45
}
 
46
 
 
47
case "$1" in
 
48
  start)
 
49
    log_daemon_msg "Starting $DESC: $NAME"
 
50
    if ! $(check_shares); then
 
51
      log_warning_msg "No shares available ..."
 
52
      log_end_msg 0
 
53
    else
 
54
      checkpid
 
55
      start-stop-daemon --start --quiet --background --oknodo \
 
56
        --make-pidfile --pidfile $PIDFILE \
 
57
        --exec $DAEMON -- $USHARE_OPTIONS
 
58
      log_end_msg $?
 
59
    fi
 
60
  ;;
 
61
  stop)
 
62
    log_daemon_msg "Stopping $DESC: $NAME"
 
63
    start-stop-daemon --stop --signal 2 --quiet --oknodo --pidfile $PIDFILE
 
64
    log_end_msg $?
 
65
  ;;
 
66
  reload|force-reload)
 
67
    log_daemon_msg "Reloading $DESC: $NAME"
 
68
    start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
 
69
    log_end_msg $?
 
70
  ;;
 
71
  restart)
 
72
    $0 stop
 
73
    sleep 1
 
74
    $0 start
 
75
  ;;
 
76
  *)
 
77
    N=/etc/init.d/$NAME
 
78
    log_success_msg "Usage: $N {start|stop|restart|reload|force-reload}"
 
79
    exit 1
 
80
  ;;
 
81
esac
 
82
 
 
83
exit 0