summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMartin Prochnow <nordlicht@martins-kabuff.de>2006-03-29 18:54:49 +0200
committerAndreas Mair <andreas@vdr-developer.org>2006-03-29 18:54:49 +0200
commit0ff08f0bfb1460e0d0035081956a75b92aaa8359 (patch)
tree3a77a0dec260c32659bf7dda9e35ef04299b8d47 /scripts
parent54d5f6870a7351584fcb1c3e861a4fc9224badf3 (diff)
downloadvdr-plugin-extrecmenu-0ff08f0bfb1460e0d0035081956a75b92aaa8359.tar.gz
vdr-plugin-extrecmenu-0ff08f0bfb1460e0d0035081956a75b92aaa8359.tar.bz2
Version 0.8v0.8
- added some logging - added option to hide the "new recordings column" - added possibility to edit lifetime and priority at the rename menu - changed alternative new marker, it marks now the recordings that are not "rewinded", if turned of the behaviour is like that of VDR's recordings menu - added support for a file length.vdr, containing the length of a recording as a string - new version of 'dvdarchive.sh'; thanks to vejoun from vdr-portal.de - added two small tools (in tools/); isodetect to check for a dvd in drive (optionally used by 'dvdarchive.sh'); getlength to create a length.vdr - updated error messages, more detailed now - fixed quoting of the parameters for dvdarchive.sh to avoid problems with filenames containing a ' - fixed unnecessary calls of 'dvdarchive.sh'; thanks to vejoun from vdr-portal.de for reporting
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dvdarchive.sh101
-rwxr-xr-xscripts/dvdarchive.sh.old37
2 files changed, 71 insertions, 67 deletions
diff --git a/scripts/dvdarchive.sh b/scripts/dvdarchive.sh
index 70770ce..dfdee0a 100755
--- a/scripts/dvdarchive.sh
+++ b/scripts/dvdarchive.sh
@@ -1,49 +1,90 @@
#!/bin/bash
+#
+# Version 1.1 2006-03-27
+#
+# Exitcodes:
+#
+# exit 0 - no error
+# exit 1 - mount/umount error
+# exit 2 - no dvd in drive
+# exit 3 - wrong dvd in drive / recording not found
+# exit 4 - error while linking [0-9]*.vdr
+#
+# Errorhandling/Symlinking: vejoun@vdr-portal
+#
+# For dvd-in-drive detection download isodetect.c, compile it and put it into the PATH,
+# usually /usr/local/bin/
+#
+
+#<Configuration>
MOUNTCMD="/usr/bin/sudo /bin/mount"
UMOUNTCMD="/usr/bin/sudo /bin/umount"
MOUNTPOINT="/media/cdrom" # no trailing '/'!
-PATH="$2"
+#</Configuration>
+
+DEVICE="$(grep "$MOUNTPOINT" /etc/fstab | head -n1 | awk '{ print $1; }')" # dvd-device, used by isodetect if exists
+
+REC="$2"
NAME="$3"
case "$1" in
mount)
- # mount dvd
- $MOUNTCMD "$MOUNTPOINT"
- if [ $? -eq 0 ]
- then
- DIR="$(/usr/bin/find "${MOUNTPOINT}/" -name "$NAME")"
- # link vdr files
- /bin/cp -s "${DIR}/index.vdr" "${PATH}/"
- /bin/cp -s "${DIR}/"???.vdr "${PATH}/"
- if [ $? -ne 0 ]
- then
- $UMOUNTCMD "$MOUNTPOINT"
- # unlink broken links
- for LINK in "${PATH}/"*.vdr; do
- if [ -L "$LINK" -a ! -s "$LINK" ]; then
- /bin/rm "$LINK"
- fi
- done
+ # check if dvd is in drive, only if isodetect exists
+ if [ -n "$(which isodetect)" -a -n "$DEVICE" ]; then
+ isodetect -d "$DEVICE" >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo "no dvd in drive"
exit 2
fi
- else
- exit 1
- fi
- ;;
-umount)
- $MOUNTCMD | /bin/grep "$MOUNTPOINT" > /dev/null
- if [ $? -eq 0 ]
- then
- # umount dvd
- $UMOUNTCMD "$MOUNTPOINT"
+ fi
+ # check if not mounted
+ $MOUNTCMD | grep "$MOUNTPOINT" >/dev/null && { echo "dvd already mounted"; exit 1; }
+ # mount dvd
+ $MOUNTCMD "$MOUNTPOINT" || { echo "dvd mount error"; exit 1; }
+ # is mounted?
+ # find recording on dvd
+ DIR="$(find "${MOUNTPOINT}/" -name "$NAME")"
+ # if not found, umount
+ if [ -z "$DIR" ]; then
+ $UMOUNTCMD "$MOUNTPOINT" || { echo "dvd umount error"; exit 1; }
+ echo "wrong dvd in drive / recording not found on dvd"
+ exit 3
+ fi
+ # link index.vdr if not exist
+ if [ ! -e "${REC}/index.vdr" ]; then
+ cp -s "${DIR}/index.vdr" "${REC}/"
+ fi
+ # link [0-9]*.vdr files
+ cp -s "${DIR}/"[0-9]*.vdr "${REC}/"
+ # error while linking [0-9]*.vdr files?
+ if [ $? -ne 0 ]; then
+ # umount dvd bevor unlinking
+ $UMOUNTCMD "$MOUNTPOINT" || { echo "dvd umount error"; exit 1; }
# unlink broken links
- for LINK in "${PATH}/"*.vdr; do
+ for LINK in "${REC}/"*.vdr; do
if [ -L "$LINK" -a ! -s "$LINK" ]; then
- /bin/rm "$LINK"
+ rm "$LINK"
fi
done
+ echo "error while linking [0-9]*.vdr"
+ exit 4
fi
;;
+umount)
+ # check if dvd is mounted
+ $MOUNTCMD | grep "$MOUNTPOINT" >/dev/null || { echo "dvd not mounted"; exit 1; }
+ # is mounted?
+ # umount dvd bevor unlinking
+ $UMOUNTCMD "$MOUNTPOINT" || { echo "dvd umount error"; exit 1; }
+ # unlink broken links
+ for LINK in "${REC}/"*.vdr; do
+ if [ -L "$LINK" -a ! -s "$LINK" ]; then
+ rm "$LINK"
+ fi
+ done
+ ;;
esac
+
+exit 0
diff --git a/scripts/dvdarchive.sh.old b/scripts/dvdarchive.sh.old
deleted file mode 100755
index ffe1737..0000000
--- a/scripts/dvdarchive.sh.old
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-
-#MOUNTCMD="/bin/mount"
-MOUNTCMD="/usr/bin/sudo mount"
-#UMOUNTCMD="/bin/umount"
-UMOUNTCMD="/usr/bin/sudo umount"
-MOUNTPOINT="/media/cdrom/" # trailing '/' is important! (for find command)
-PATH=$2
-NAME=$3
-
-case "$1" in
-mount)
- # mount dvd
- $MOUNTCMD $MOUNTPOINT
- if [ $? -eq 0 ]
- then
- DIR=$(/usr/bin/find $MOUNTPOINT -name $NAME)
- # bind recording dir on dvd to recording dir in /video
- $MOUNTCMD --bind $DIR $PATH
- if [ $? -ne 0 ]
- then
- $UMOUNTCMD $MOUNTPOINT
- exit 2
- fi
- else
- exit 1
- fi
- ;;
-umount)
- $MOUNTCMD | /bin/grep $PATH > /dev/null
- if [ $? -eq 0 ]
- then
- $UMOUNTCMD $PATH
- $UMOUNTCMD $MOUNTPOINT
- fi
- ;;
-esac