From 977fc5b849b2c2090d295575e54f097ae7e95be4 Mon Sep 17 00:00:00 2001 From: emes Date: Tue, 15 Jul 2008 16:31:26 +0000 Subject: [PATCH] - fixed init scripts Changed files: flumotion.init -> 1.1 flumotion.spec -> 1.8 --- flumotion.init | 232 +++++++++++++++++++++++++++++++++++++++++++++++++ flumotion.spec | 7 +- 2 files changed, 235 insertions(+), 4 deletions(-) create mode 100644 flumotion.init diff --git a/flumotion.init b/flumotion.init new file mode 100644 index 0000000..25b6666 --- /dev/null +++ b/flumotion.init @@ -0,0 +1,232 @@ +#!/bin/bash +# +# Startup script for the Flumotion streaming server +# +# flumotion: Flumotion Streaming Server +# +# chkconfig: - 80 20 +# +# description: Flumotion is a streaming server for audio and video. \ +# See http://www.fluendo.com for details. +# +# Source function library. +. /etc/rc.d/init.d/functions + +# paths to files and variables +service=flumotion +prog=/usr/sbin/flumotion +lockdir=/var/lock/subsys +rundir=/var/run/flumotion +logfile=/var/log/flumotion/service.log +sysconfig=/etc/sysconfig/flumotion + +# source configuration +if [ -f $sysconfig ] ; then + . $sysconfig +fi + +# to make sure our service log file is always owned by the correct user, +# we touch it +touch_logfile() { + touch $logfile + chown flumotion $logfile +} + +update_lockfile() { + # we have the subsys lock iff this script has been run and a + # flumotion process is running + # see http://www.redhat.com/magazine/008jun05/departments/tips_tricks/ + if [ -n "`find $rundir -name 'manager.*.pid' -o -name 'worker.*.pid'`" ] + then + touch ${lockdir}/flumotion + else + rm -f ${lockdir}/flumotion + fi +} + +# if arguments are specified, we only start/stop that service part +start() { + if test "x$*" != "x" + then + startone $* + return $? + fi + + RETVAL=0 + $prog status | cut -f1,2 -d' ' | while read type name + do + startone $type $name || RETVAL=1 + done + return $RETVAL +} + +startone() { + type=$1 + name=$2 + + if test "x$name" == "x" + then + echo $"Please specify a $type name" + exit 1 + fi + + msg_starting "Flumotion $type $name" + daemon --user flumotion $prog -d 3 -l $logfile start $type $name + RETVAL=$? + [ $RETVAL = 0 ] && update_lockfile + return $RETVAL +} + +stop() { + if test "x$*" != "x" + then + stopone $* + return $? + fi + + RETVAL=0 + $prog status | cut -f1,2 -d' ' | while read type name + do + if test -e ${rundir}/$type.$name.pid + then + stopone $type $name || RETVAL=1 + fi + done + return $RETVAL +} + +stopone() { + type=$1 + name=$2 + + if test "x$name" == "x" + then + echo $"Please specify a $type name" + exit 1 + fi + + touch_logfile + + RETVAL=0 + msg_stopping "Flumotion $type $name" + busy + $prog stop -d 3 -l $logfile $type $name + RETVAL=$? + [ $RETVAL = 0 ] && ok || died + [ $RETVAL = 0 ] && update_lockfile + + return $RETVAL +} + + +condrestart() { + if test "x$*" != "x" + then + condrestartone $* + return $? + fi + + RETVAL=0 + $prog status | cut -f1,2 -d' ' | while read type name + do + if test -e ${rundir}/$type.$name.pid + then + condrestartone $type $name || RETVAL=1 + fi + done + return $RETVAL +} + +condrestartone() { + type=$1 + name=$2 + + if test "x$name" == "x" + then + echo $"Please specify a $type name" + exit 1 + fi + + if test -e ${rundir}/$type.$name.pid + then + stopone $type $name || RETVAL=1 + startone $type $name || RETVAL=1 + fi + + return $RETVAL +} + +status() { + touch_logfile + if test "x$*" != "x" + then + statusone $* + return $? + fi + $prog status +} + +statusone() { + type=$1 + name=$2 + + if test "x$name" == "x" + then + echo $"Please specify a $type name" + exit 1 + fi + + touch_logfile + + $prog status $type $name + RETVAL=$? + return $RETVAL +} + +clean() { + touch_logfile + $prog clean +} + +list() { + touch_logfile + $prog list +} + +# See how we were called. +case "$1" in + start) + shift + start $* + ;; + stop) + shift + stop $* + ;; +# FIXME: now that we have condrestart, maybe restart should also handle +# stop/start per process, instead of global stop and global start ? + restart) + shift + stop $* + start $* + ;; + condrestart) + shift + condrestart $* + ;; + status) + shift + status $* + ;; + clean) + clean + ;; + list) + list + ;; + *) + echo $"Usage: $service {start|stop|restart|list|status|clean}" + exit 1 +esac + +exit $RETVAL diff --git a/flumotion.spec b/flumotion.spec index 46fa94e..4f43770 100644 --- a/flumotion.spec +++ b/flumotion.spec @@ -2,11 +2,12 @@ Summary: The Fluendo Streaming Server Summary(pl.UTF-8): Serwer strumieni Fluendo Name: flumotion Version: 0.5.1 -Release: 0.3 +Release: 0.4 License: GPL Group: Daemons Source0: http://www.flumotion.net/src/flumotion/%{name}-%{version}.tar.bz2 # Source0-md5: 70256d8d80a0d5cda61e468116ff8be2 +Source1: %{name}.init Patch0: %{name}-pdksh.patch URL: http://www.flumotion.net/ BuildRequires: automake @@ -67,9 +68,7 @@ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/flumotion # install service files install -d $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d -install -m 755 \ - doc/redhat/flumotion \ - $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d +install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/%{name} # create log and run and cache directory install -d $RPM_BUILD_ROOT%{_localstatedir}/log/flumotion -- 2.43.0