]> git.pld-linux.org Git - packages/flumotion.git/blame - flumotion.init
- more pldize
[packages/flumotion.git] / flumotion.init
CommitLineData
1de98f97 1#!/bin/sh
977fc5b8 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
1de98f97 25 . $sysconfig
977fc5b8 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/
f8bca36b 39 if [ -n "`find $rundir -name 'manager.*.pid' -o -name 'worker.*.pid'`" ]; then
977fc5b8 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
47start() {
f8bca36b 48 if [ "x$*" != "x" ]; then
977fc5b8 49 startone $*
50 return $?
51 fi
52
53 RETVAL=0
f8bca36b 54 $prog status | cut -f1,2 -d' ' | while read type name; do
977fc5b8 55 startone $type $name || RETVAL=1
56 done
57 return $RETVAL
58}
59
60startone() {
61 type=$1
62 name=$2
63
f8bca36b 64 if [ "x$name" == "x" ]; then
1de98f97 65 nls "Please specify a $type name"
977fc5b8 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
76stop() {
f8bca36b 77 if [ "x$*" != "x" ]; then
977fc5b8 78 stopone $*
79 return $?
80 fi
81
82 RETVAL=0
f8bca36b
ER
83 $prog status | cut -f1,2 -d' ' | while read type name; do
84 if [ -e ${rundir}/$type.$name.pid ]; then
977fc5b8 85 stopone $type $name || RETVAL=1
86 fi
87 done
88 return $RETVAL
89}
90
91stopone() {
92 type=$1
93 name=$2
94
f8bca36b 95 if [ "x$name" == "x" ]; then
1de98f97 96 nls "Please specify a $type name"
977fc5b8 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
977fc5b8 113condrestart() {
f8bca36b 114 if [ "x$*" != "x" ]; then
977fc5b8 115 condrestartone $*
116 return $?
117 fi
118
119 RETVAL=0
f8bca36b
ER
120 $prog status | cut -f1,2 -d' ' | while read type name; do
121 if [ -e ${rundir}/$type.$name.pid ]; then
977fc5b8 122 condrestartone $type $name || RETVAL=1
123 fi
124 done
125 return $RETVAL
126}
127
128condrestartone() {
129 type=$1
130 name=$2
131
f8bca36b 132 if [ "x$name" == "x" ]; then
1de98f97 133 nls "Please specify a $type name"
977fc5b8 134 exit 1
135 fi
136
f8bca36b 137 if [ -e ${rundir}/$type.$name.pid ]; then
977fc5b8 138 stopone $type $name || RETVAL=1
139 startone $type $name || RETVAL=1
140 fi
141
142 return $RETVAL
143}
144
145status() {
f8bca36b
ER
146 touch_logfile
147 if [ "x$*" != "x" ]; then
977fc5b8 148 statusone $*
149 return $?
150 fi
151 $prog status
152}
153
154statusone() {
155 type=$1
156 name=$2
157
f8bca36b 158 if [ "x$name" == "x" ]; then
1de98f97 159 nls "Please specify a $type name"
977fc5b8 160 exit 1
161 fi
162
163 touch_logfile
164
165 $prog status $type $name
166 RETVAL=$?
167 return $RETVAL
168}
169
170clean() {
f8bca36b 171 touch_logfile
977fc5b8 172 $prog clean
173}
174
175list() {
f8bca36b 176 touch_logfile
977fc5b8 177 $prog list
178}
179
180# See how we were called.
181case "$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 ;;
1de98f97 197 try-restart|force-reload)
977fc5b8 198 shift
199 condrestart $*
200 ;;
201 status)
202 shift
203 status $*
204 ;;
205 clean)
f8bca36b 206 clean
977fc5b8 207 ;;
208 list)
f8bca36b 209 list
977fc5b8 210 ;;
211 *)
f8bca36b
ER
212 msg_usage "$0 {start|stop|restart|try-restart|force-reload|list|status|clean}"
213 exit 3
977fc5b8 214esac
215
216exit $RETVAL
This page took 0.117832 seconds and 4 git commands to generate.