~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to utopic/etc/init.d/core-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:          core-daemon
4
 
# Required-Start:    $network $remote_fs
5
 
# Required-Stop:     $network $remote_fs
6
 
# Default-Start:     2 3 4 5
7
 
# Default-Stop:      0 1 6
8
 
# Short-Description: Start the core-daemon CORE daemon at boot time
9
 
# Description:       Starts and stops the core-daemon CORE daemon used to
10
 
#                    provide network emulation services for the CORE GUI
11
 
#                    or scripts.
12
 
### END INIT INFO
13
 
#
14
 
# chkconfig: 35 90 03
15
 
# description: Starts and stops the CORE daemon \
16
 
#              used to provide network emulation services.
17
 
#
18
 
# pidfile: /var/run/core-daemon.pid
19
 
# config:  /usr/local/etc/core/
20
 
 
21
 
DEB=no
22
 
# Source function library.
23
 
if [ -f /etc/init.d/functions ] ; then
24
 
  . /etc/init.d/functions
25
 
elif [ -f /etc/rc.d/init.d/functions ] ; then
26
 
  . /etc/rc.d/init.d/functions
27
 
elif [ -f /lib/lsb/init-functions ] ; then
28
 
  . /lib/lsb/init-functions
29
 
  DEB=yes
30
 
else
31
 
  exit 1
32
 
fi
33
 
 
34
 
# search for core-daemon which may or may not be installed
35
 
cored=
36
 
for p in /usr/local/sbin \
37
 
         /usr/sbin \
38
 
         /sbin \
39
 
         /usr/local/bin \
40
 
         /usr/bin \
41
 
         /bin
42
 
do
43
 
  if [ -e $p/core-daemon ] ; then
44
 
    cored=$p/core-daemon
45
 
    break
46
 
  fi
47
 
done
48
 
 
49
 
# this function comes from /etc/profile
50
 
pathmunge () {
51
 
    if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
52
 
       if [ "$2" = "after" ] ; then
53
 
          PATH=$PATH:$1
54
 
       else
55
 
          PATH=$1:$PATH
56
 
       fi
57
 
    fi
58
 
}
59
 
 
60
 
# these lines add to the PATH variable used by CORE and its containers
61
 
# you can add your own pathmunge statements to change the container's PATH
62
 
pathmunge "/usr/local/sbin"
63
 
pathmunge "/usr/local/bin"
64
 
 
65
 
RETVAL=0
66
 
PIDFILE=/var/run/core-daemon.pid
67
 
 
68
 
# the /etc/init.d/functions (RedHat) differs from
69
 
#     /usr/lib/init-functions (Debian)
70
 
if [ $DEB = yes ]; then
71
 
  daemon="start-stop-daemon --start -p ${PIDFILE} --exec /usr/bin/python --"
72
 
  #daemon=start_daemon
73
 
  status=status_of_proc
74
 
  msg () {
75
 
    log_daemon_msg "$@"
76
 
  }
77
 
  endmsg () {
78
 
    echo ""
79
 
  }
80
 
else
81
 
  daemon="daemon /usr/bin/python"
82
 
  status=status
83
 
  msg () {
84
 
    echo -n $"$@"
85
 
  }
86
 
  endmsg () {
87
 
    echo ""
88
 
  }
89
 
fi
90
 
 
91
 
 
92
 
start() {
93
 
        msg "Starting core-daemon"
94
 
        $daemon $cored -d
95
 
        RETVAL=$?
96
 
        endmsg
97
 
        return $RETVAL
98
 
}       
99
 
 
100
 
stop() {
101
 
        msg "Shutting down core-daemon"
102
 
        killproc -p ${PIDFILE} $cored
103
 
        RETVAL=$?
104
 
        rm -f ${PIDFILE}
105
 
        endmsg
106
 
        return $RETVAL
107
 
}       
108
 
 
109
 
restart() {
110
 
        stop
111
 
        start
112
 
}       
113
 
 
114
 
corestatus() {
115
 
        $status -p ${PIDFILE} core-daemon core-daemon
116
 
        return $?
117
 
}       
118
 
 
119
 
 
120
 
case "$1" in
121
 
  start)
122
 
        start
123
 
        ;;
124
 
  stop)
125
 
        stop
126
 
        ;;
127
 
  restart)
128
 
        restart
129
 
        ;;
130
 
  force-reload)
131
 
        restart
132
 
        ;;
133
 
  status)
134
 
        corestatus
135
 
        ;;
136
 
  *)
137
 
        msg "Usage: $0 {start|stop|restart|status}"
138
 
        endmsg
139
 
        exit 2
140
 
esac
141
 
 
142
 
exit $?