]> git.pld-linux.org Git - packages/flumotion.git/blob - flumotion.init
- more pldize
[packages/flumotion.git] / flumotion.init
1 #!/bin/sh
2 #
3 # Startup script for the Flumotion streaming server
4 #
5 # flumotion: Flumotion Streaming Server
6 #
7 # chkconfig: - 80 20
8 #
9 # description: Flumotion is a streaming server for audio and video. \
10 #              See http://www.fluendo.com for details.
11 #
12 # Source function library.
13 . /etc/rc.d/init.d/functions
14
15 # paths to files and variables
16 service=flumotion
17 prog=/usr/sbin/flumotion
18 lockdir=/var/lock/subsys
19 rundir=/var/run/flumotion
20 logfile=/var/log/flumotion/service.log
21 sysconfig=/etc/sysconfig/flumotion
22
23 # source configuration 
24 if [ -f $sysconfig ] ; then
25         . $sysconfig
26 fi
27
28 # to make sure our service log file is always owned by the correct user,
29 # we touch it
30 touch_logfile() {
31         touch $logfile
32         chown flumotion $logfile
33 }
34
35 update_lockfile() {
36         # we have the subsys lock iff this script has been run and a
37         # flumotion process is running
38         # see http://www.redhat.com/magazine/008jun05/departments/tips_tricks/
39         if [ -n "`find $rundir -name 'manager.*.pid' -o -name 'worker.*.pid'`" ]; then
40                 touch ${lockdir}/flumotion
41         else
42                 rm -f ${lockdir}/flumotion
43         fi
44 }
45
46 # if arguments are specified, we only start/stop that service part
47 start() {
48         if [ "x$*" != "x" ]; then
49                 startone $*
50                 return $?
51         fi
52
53         RETVAL=0
54         $prog status | cut -f1,2 -d' ' | while read type name; do
55                 startone $type $name || RETVAL=1
56         done
57         return $RETVAL
58 }
59
60 startone() {
61         type=$1
62         name=$2
63
64         if [ "x$name" == "x" ]; then
65                 nls "Please specify a $type name"
66                 exit 1
67         fi
68
69         msg_starting "Flumotion $type $name"
70         daemon --user flumotion $prog -d 3 -l $logfile start $type $name
71         RETVAL=$?
72         [ $RETVAL = 0 ] && update_lockfile
73         return $RETVAL
74 }
75
76 stop() {
77         if [ "x$*" != "x" ]; then
78                 stopone $*
79                 return $?
80         fi
81
82         RETVAL=0
83         $prog status | cut -f1,2 -d' ' | while read type name; do
84                 if [ -e ${rundir}/$type.$name.pid ]; then
85                     stopone $type $name || RETVAL=1
86                 fi
87         done
88         return $RETVAL
89 }
90
91 stopone() {
92         type=$1
93         name=$2
94
95         if [ "x$name" == "x" ]; then
96                 nls "Please specify a $type name"
97                 exit 1
98         fi
99
100         touch_logfile
101
102         RETVAL=0
103         msg_stopping "Flumotion $type $name"
104         busy
105         $prog stop -d 3 -l $logfile $type $name
106         RETVAL=$?
107         [ $RETVAL = 0 ] && ok || died
108         [ $RETVAL = 0 ] && update_lockfile
109
110         return $RETVAL
111 }
112
113 condrestart() {
114         if [ "x$*" != "x" ]; then
115                 condrestartone $*
116                 return $?
117         fi
118
119         RETVAL=0
120         $prog status | cut -f1,2 -d' ' | while read type name; do
121                 if [ -e ${rundir}/$type.$name.pid ]; then
122                     condrestartone $type $name || RETVAL=1
123                 fi
124         done
125         return $RETVAL
126 }
127
128 condrestartone() {
129         type=$1
130         name=$2
131
132         if [ "x$name" == "x" ]; then
133                 nls "Please specify a $type name"
134                 exit 1
135         fi
136
137         if [ -e ${rundir}/$type.$name.pid ]; then
138             stopone $type $name || RETVAL=1
139             startone $type $name || RETVAL=1
140         fi
141
142         return $RETVAL
143 }
144
145 status() {
146         touch_logfile
147         if [ "x$*" != "x" ]; then
148                 statusone $*
149                 return $?
150         fi
151         $prog status
152 }
153
154 statusone() {
155         type=$1
156         name=$2
157
158         if [ "x$name" == "x" ]; then
159                 nls "Please specify a $type name"
160                 exit 1
161         fi
162
163         touch_logfile
164
165         $prog status $type $name
166         RETVAL=$?
167         return $RETVAL
168 }
169
170 clean() {
171         touch_logfile
172         $prog clean
173 }
174
175 list() {
176         touch_logfile
177         $prog list
178 }
179
180 # See how we were called.
181 case "$1" in
182   start)
183         shift
184         start $*
185         ;;
186   stop)
187         shift
188         stop $*
189         ;;
190 # FIXME: now that we have condrestart, maybe restart should also handle
191 # stop/start per process, instead of global stop and global start ?
192   restart)
193         shift
194         stop $*
195         start $*
196         ;;
197   try-restart|force-reload)
198         shift
199         condrestart $*
200         ;;
201   status)
202         shift
203         status $*
204         ;;
205   clean)
206         clean
207         ;;
208   list)
209         list
210         ;;
211   *)
212         msg_usage "$0 {start|stop|restart|try-restart|force-reload|list|status|clean}"
213         exit 3
214 esac
215
216 exit $RETVAL
This page took 0.085577 seconds and 3 git commands to generate.