vdr/vdr/debian README.Debian S90.custom vdr-recordingaction vdr-shutdown
Tobias Grimm
pkg-vdr-dvb-changes@lists.alioth.debian.org
Thu, 03 Jun 2004 00:21:38 +0000
Update of /cvsroot/pkg-vdr-dvb/vdr/vdr/debian
In directory haydn:/tmp/cvs-serv13099
Modified Files:
README.Debian S90.custom vdr-recordingaction vdr-shutdown
Log Message:
added shutdown script (mainly untested at the moment!)
Index: vdr-shutdown
===================================================================
RCS file: /cvsroot/pkg-vdr-dvb/vdr/vdr/debian/vdr-shutdown,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- vdr-shutdown 29 May 2004 23:48:22 -0000 1.1
+++ vdr-shutdown 3 Jun 2004 00:21:36 -0000 1.2
@@ -1,5 +1,57 @@
#!/bin/sh
+#
+# VDR Shutdown Script - Tobias Grimm <tg@e-tobi.net>
+# -------------------
+#
+# see README.Debian
+#
-SHUTDOWN_HOOKS_DIR=/usr/share/vdr/shutdown-hooks
+SHUTDOWN_HOOKS_DIR=/usr/share/vdr/shutdown-hooks/
-# TODO - Be patient... will come soon
+log="logger -t vdr-shutdown"
+svdrpsend="/usr/lib/vdr/svdrpsend.pl"
+osdmsg="$svdrpsend MESG"
+
+MAX_TRY_AGAIN=0
+SHUTDOWNCMD="/etc/init.d/vdr stop ; sleep 1 ; /sbin/shutdown -h now"
+
+shutdownhooks=`find $SHUTDOWN_HOOKS_DIR -maxdepth 1 -xtype f | sort`
+
+for shutdownhook in $shutdownhooks; do
+ TRY_AGAIN=0
+
+ if [ -x $shutdownhook ]; then
+ $log "executing $shutdownhook"
+ result_data=`$shutdownhook $*`
+ else
+ $log "executing $shutdownhook as shell script"
+ result_data=`/bin/sh $shutdownhook $*`
+ fi
+ result=$?
+ eval $result_data
+ if [ $result -ne 0 ] ; then
+ $log "Shutdown aborted by $shutdownhook with exitcode $result"
+ $osdmsg "Shutdown abgebrochen / Shutdown aborted!"
+ [ ! -z $ABORT_MESSAGE ] && $osdmsg $ABORT_MESSAGE
+ exit $result
+ fi
+
+ if [ $TRY_AGAIN -gt 0 ]
+ then
+ $log "$shutdownhook requests to try again in $TRY_AGAIN minutes"
+ if [ $MAX_TRY_AGAIN -lt $TRY_AGAIN ]
+ then
+ MAX_TRY_AGAIN=$TRY_AGAIN
+ fi
+ fi
+done
+
+if [ $MAX_TRY_AGAIN -gt 0 ]
+then
+ $log "Will try again shutdown in $MAX_TRY_AGAIN minutes."
+ echo "$svdrpsend HITK Power" | at now
+ $osdmsg "Shutdown aborted. Retry in $MAX_TRY_AGAIN minutes."
+ exit 0
+fi
+
+eval $SHUTDOWNCMD
Index: README.Debian
===================================================================
RCS file: /cvsroot/pkg-vdr-dvb/vdr/vdr/debian/README.Debian,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- README.Debian 29 May 2004 23:48:22 -0000 1.6
+++ README.Debian 3 Jun 2004 00:21:36 -0000 1.7
@@ -113,6 +113,39 @@
Shutdown-Hooks
---------------
-TODO !!!
+If you press the power key on your remote control, VDR executes a script
+provided by the command line option -s. By default, this script will
+execute all files in /usr/share/vdr/command-hooks in their alphabetical order.
+If a file in there is not executable, it is treated as a shell script. These
+so called "Shutdown Hooks" should follow this naming scheme:
- -- Tobias Grimm <tg@e-tobi.net>, Sun, 23 May 2004 19:00:00 +0100
+S<XX>.<identifier>
+
+Where <XX> is a two digit number, that mainly specifies the execution order
+and <identifier> is a unique descriptor.
+
+All shutdown hooks will be passed the same parameters as the main shutdown
+script. I.e. the first parameter is the start time of the next timer. Please
+refer to the vdr documentation for the other parameters.
+
+After all shutdown hooks have been process, VDR will be terminated and the
+machine will be shut down.
+
+A shutdown hook may abort the shutdown process by exiting with an errorlevel
+unequal to 0. To provide the user with an OSD-message about the reason for
+aborting the shutdown, the shutdown hook may write an abort message to stdout
+like this:
+
+ABORT_MESSAGE=<message to display>
+
+If the shutdown should only be deferred (i.e. because some background process,
+is still active), the shutdown hook may write to stdout:
+
+TRY_AGAIN=<minutes to wait before next shutdown request>
+
+To overwrite the command that will be executed to shutdown the machine after
+all shutdown hooks have been processed, the shutdown hook may write to stdout:
+
+SHUTDOWNCMD=<new shutdown command>
+
+ -- Tobias Grimm <tg@e-tobi.net>, Thu, 3 Jun 2004 02:20:00 +0100
Index: S90.custom
===================================================================
RCS file: /cvsroot/pkg-vdr-dvb/vdr/vdr/debian/S90.custom,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- S90.custom 31 May 2004 11:54:04 -0000 1.2
+++ S90.custom 3 Jun 2004 00:21:36 -0000 1.3
@@ -2,5 +2,28 @@
# Custom VDR Shutdown Hook
# -------------------------
#
+# Here you can place any commands, you want to be executed when VDR wants
+# to shutdown.
+#
+# * To abort the shutdown, exit with an errorlevel <> 0.
+#
+# * If you want a message to be displayed on the OSD when aborting a shutdown,
+# then write to stdout:
+#
+# ABORT_MESSAGE=<message to display>
+#
+# * If you want to defer the shutdown, write to stdout:
+#
+# TRY_AGAIN=<minutes to wait before next shutdown request>
+#
+# * To overwrite the command that will be executed to shutdown the machine
+# after all shutdown hooks have been processed, write to stdout:
+#
+# SHUTDOWNCMD=<new shutdown command>
+#
+# i.e.:
+#
+# echo "ABORT_MESSAGE=\"I do not want to shutdown now!\"" ; exit 1
+#
+
-# TODO
Index: vdr-recordingaction
===================================================================
RCS file: /cvsroot/pkg-vdr-dvb/vdr/vdr/debian/vdr-recordingaction,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- vdr-recordingaction 23 May 2004 17:16:01 -0000 1.1
+++ vdr-recordingaction 3 Jun 2004 00:21:36 -0000 1.2
@@ -27,7 +27,7 @@
REC_HOOKS_DIR=/usr/share/vdr/recording-hooks
-recordinghooks=`find $REC_HOOKS_DIR -maxdepth 1 -perm +111 -xtype f | sort`
+recordinghooks=`find $REC_HOOKS_DIR -maxdepth 1 -xtype f | sort`
for recordinghook in $recordinghooks; do
case $1 in