]> git.pld-linux.org Git - packages/flumotion.git/blame - flumotion.init
- fixed init scripts
[packages/flumotion.git] / flumotion.init
CommitLineData
977fc5b8 1#!/bin/bash
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
16service=flumotion
17prog=/usr/sbin/flumotion
18lockdir=/var/lock/subsys
19rundir=/var/run/flumotion
20logfile=/var/log/flumotion/service.log
21sysconfig=/etc/sysconfig/flumotion
22
23# source configuration
24if [ -f $sysconfig ] ; then
25 . $sysconfig
26fi
27
28# to make sure our service log file is always owned by the correct user,
29# we touch it
30touch_logfile() {
31 touch $logfile
32 chown flumotion $logfile
33}
34
35update_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'`" ]
40 then
41 touch ${lockdir}/flumotion
42 else
43 rm -f ${lockdir}/flumotion
44 fi
45}
46
47# if arguments are specified, we only start/stop that service part
48start() {
49 if test "x$*" != "x"
50 then
51 startone $*
52 return $?
53 fi
54
55 RETVAL=0
56 $prog status | cut -f1,2 -d' ' | while read type name
57 do
58 startone $type $name || RETVAL=1
59 done
60 return $RETVAL
61}
62
63startone() {
64 type=$1
65 name=$2
66
67 if test "x$name" == "x"
68 then
69 echo $"Please specify a $type name"
70 exit 1
71 fi
72
73 msg_starting "Flumotion $type $name"
74 daemon --user flumotion $prog -d 3 -l $logfile start $type $name
75 RETVAL=$?
76 [ $RETVAL = 0 ] && update_lockfile
77 return $RETVAL
78}
79
80stop() {
81 if test "x$*" != "x"
82 then
83 stopone $*
84 return $?
85 fi
86
87 RETVAL=0
88 $prog status | cut -f1,2 -d' ' | while read type name
89 do
90 if test -e ${rundir}/$type.$name.pid
91 then
92 stopone $type $name || RETVAL=1
93 fi
94 done
95 return $RETVAL
96}
97
98stopone() {
99 type=$1
100 name=$2
101
102 if test "x$name" == "x"
103 then
104 echo $"Please specify a $type name"
105 exit 1
106 fi
107
108 touch_logfile
109
110 RETVAL=0
111 msg_stopping "Flumotion $type $name"
112 busy
113 $prog stop -d 3 -l $logfile $type $name
114 RETVAL=$?
115 [ $RETVAL = 0 ] && ok || died
116 [ $RETVAL = 0 ] && update_lockfile
117
118 return $RETVAL
119}
120
121
122condrestart() {
123 if test "x$*" != "x"
124 then
125 condrestartone $*
126 return $?
127 fi
128
129 RETVAL=0
130 $prog status | cut -f1,2 -d' ' | while read type name
131 do
132 if test -e ${rundir}/$type.$name.pid
133 then
134 condrestartone $type $name || RETVAL=1
135 fi
136 done
137 return $RETVAL
138}
139
140condrestartone() {
141 type=$1
142 name=$2
143
144 if test "x$name" == "x"
145 then
146 echo $"Please specify a $type name"
147 exit 1
148 fi
149
150 if test -e ${rundir}/$type.$name.pid
151 then
152 stopone $type $name || RETVAL=1
153 startone $type $name || RETVAL=1
154 fi
155
156 return $RETVAL
157}
158
159status() {
160 touch_logfile
161 if test "x$*" != "x"
162 then
163 statusone $*
164 return $?
165 fi
166 $prog status
167}
168
169statusone() {
170 type=$1
171 name=$2
172
173 if test "x$name" == "x"
174 then
175 echo $"Please specify a $type name"
176 exit 1
177 fi
178
179 touch_logfile
180
181 $prog status $type $name
182 RETVAL=$?
183 return $RETVAL
184}
185
186clean() {
187 touch_logfile
188 $prog clean
189}
190
191list() {
192 touch_logfile
193 $prog list
194}
195
196# See how we were called.
197case "$1" in
198 start)
199 shift
200 start $*
201 ;;
202 stop)
203 shift
204 stop $*
205 ;;
206# FIXME: now that we have condrestart, maybe restart should also handle
207# stop/start per process, instead of global stop and global start ?
208 restart)
209 shift
210 stop $*
211 start $*
212 ;;
213 condrestart)
214 shift
215 condrestart $*
216 ;;
217 status)
218 shift
219 status $*
220 ;;
221 clean)
222 clean
223 ;;
224 list)
225 list
226 ;;
227 *)
228 echo $"Usage: $service {start|stop|restart|list|status|clean}"
229 exit 1
230esac
231
232exit $RETVAL
This page took 0.086419 seconds and 4 git commands to generate.