#!/bin/sh # # chkconfig: 345 94 6 # description: Video Disk Recorder ### BEGIN INIT INFO # Provides: vdr # Should-Start: $network $local_fs $remote_fs harddrake # Default-Start: 3 4 5 # Short-Description: Video Disk Recorder # Description: This script launches the Video Disc Recorder ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions # Support symlinking initscripts to run multiple vdr daemons with different # configurations DAEMONNAME="vdr${0##*vdr}" RUNVDRNAME="run${DAEMONNAME}" # Get config. VDR_NICE=0 VDR_PLUGINS="any" VDR_RESTART_ON_INSTALL=no VDR_RESTART_ON_REMOVE=no VDR_RESTART_ON_UPGRADE=yes . /etc/sysconfig/$DAEMONNAME NICELEVEL="$VDR_NICE" LOCKFILE=/var/lock/subsys/$DAEMONNAME run_ccp_for_plugin() { PLUGIN="$1" if test -e /etc/sysconfig/vdr-$PLUGIN.rpmnew && test -e /etc/sysconfig/vdr-$PLUGIN && \ test $(stat -c%Z /etc/sysconfig/vdr-$PLUGIN.rpmnew) -gt $(stat -c%Z /etc/sysconfig/vdr-$PLUGIN); then ccp --backup --delete --ifexists --set NoOrphans --oldfile \ /etc/sysconfig/vdr-$PLUGIN --newfile /etc/sysconfig/vdr-$PLUGIN.rpmnew fi } case "$1" in start) gprintf "Starting %s: " "Video Disk Recorder" daemon env -i BASH_ENV=/etc/profile /bin/bash $RUNVDRNAME --background RETVAL=$? echo touch $LOCKFILE ;; stop) gprintf "Shutting down %s: " "Video Disk Recorder" killproc $RUNVDRNAME -TERM RETVAL=$? SECS=0 while status $RUNVDRNAME >/dev/null; do sleep 1 SECS=$((SECS+1)) test $SECS -eq 25 && break done RETVAL=0 status $RUNVDRNAME >/dev/null && (killproc $RUNVDRNAME; RETVAL=$?) echo rm -f $LOCKFILE ;; status) status $RUNVDRNAME RETVAL=$? ;; reload|restart) $0 stop $0 start RETVAL=$? ;; condrestart_plugin) RETVAL=0 for f in $VDR_PLUGINS; do if [ "$f" == "$2" ] || [ "$f" == "any" ]; then $0 stop $0 start RETVAL=$? break fi done ;; plugin_install) run_ccp_for_plugin $2 [ "$VDR_RESTART_ON_INSTALL" == "yes" ] || exit 0 status $RUNVDRNAME >/dev/null || exit 0 $0 condrestart_plugin $2 RETVAL=$? ;; plugin_remove) [ "$VDR_RESTART_ON_REMOVE" == "yes" ] || exit 0 status $RUNVDRNAME >/dev/null || exit 0 $0 condrestart_plugin $2 RETVAL=$? ;; plugin_upgrade) run_ccp_for_plugin $2 [ "$VDR_RESTART_ON_UPGRADE" == "yes" ] || exit 0 status $RUNVDRNAME >/dev/null || exit 0 $0 condrestart_plugin $2 RETVAL=$? ;; *) gprintf "Usage: %s\n" "$0 {start|stop|restart|reload|status}" exit 1 esac exit $RETVAL