From 40d2369b12da350f684f5364a00c3501a6c038e6 Mon Sep 17 00:00:00 2001 From: Martin Prochnow Date: Mon, 29 May 2006 16:02:12 +0200 Subject: =?UTF-8?q?Version=200.11=20-=20added=20czech=20translation;=20tha?= =?UTF-8?q?nks=20to=20Vladim=EDr=20B=E1rta=20-=20added=20missing=20dialog?= =?UTF-8?q?=20for=20video=20dvds=20-=20added=20more=20meaningful=20error?= =?UTF-8?q?=20messages=20-=20avoid=20empty=20names=20and=20names=20startin?= =?UTF-8?q?g=20with=20.=20or=20..=20while=20editing=20-=20free=20space=20d?= =?UTF-8?q?isplay=20in=20title=20bar=20is=20now=20updated=20immediately=20?= =?UTF-8?q?-=20switched=20off=20editing=20of=20recordings=20and=20director?= =?UTF-8?q?ies=20while=20a=20cut=20is=20in=20progress=20-=20switched=20off?= =?UTF-8?q?=20resume=20by=20'Play'=20or=20'Menu'->'Blue'=20for=20archive?= =?UTF-8?q?=20dvd=20recordings=20-=20changed=20back=20the=20behaviour=20if?= =?UTF-8?q?=20replay=20ends;=20plugin=20has=20to=20open=20to=20unmount=20a?= =?UTF-8?q?rchive=20dvds=20-=20removed=20setup=20option=20"While=20opening?= =?UTF-8?q?=20jump=20to=20last=20replayed=20recording";=20its=20implementi?= =?UTF-8?q?on=20interfers=20with=20the=20following=20one=20-=20after=20ren?= =?UTF-8?q?aming=20a=20recording,=20the=20selection=20bar=20now=20stays=20?= =?UTF-8?q?at=20this=20renamed=20list=20entry=20-=20the=20parameters=20'mo?= =?UTF-8?q?ve'=20and=20'rename'=20for=20the=20'-r'-option=20of=20VDR=20hav?= =?UTF-8?q?e=20now=20the=20following=20format:=20move/rename=20oldname=20n?= =?UTF-8?q?ewname=20-=20fixed=20hopefully=20all=20problems=20in=20connecti?= =?UTF-8?q?on=20with=20renaming=20and=20moving=20directories=20-=20plugins?= =?UTF-8?q?=20closes=20if=20there=20are=20no=20recordings=20-=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/dvdarchive.sh | 83 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 23 deletions(-) (limited to 'scripts') diff --git a/scripts/dvdarchive.sh b/scripts/dvdarchive.sh index cf545ee..c4cf157 100755 --- a/scripts/dvdarchive.sh +++ b/scripts/dvdarchive.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Version 1.9 2006-04-28 +# Version 2.0 2006-05-03 # # Author: Mike Constabel # VDR-Portal: vejoun @@ -41,6 +41,10 @@ # the script will create a length.vdr for you. # # 6. +# If something went wrong, set DEBUG=1 and send me the file which is defined in $DEBUGLOG. +# Use VDR-Portal or EMail. +# +# 7. # Exitcodes: # # exit 0 - no error @@ -52,6 +56,10 @@ # # HISTORY: # -------- +# 2.0 - more logging +# - check if mountpoint and device exists +# - Debug Log in file $DEBUGLOG if $DEBUG is 1, for easier error reporting +# # 1.9 - use "sudo mount --bind" for mounting if filesystem is vfat # - automatic fallback to 'sudo' and 'mount --bind' if filesystem is vfat # - mounting more failure tolerant @@ -62,7 +70,8 @@ # - on mount, if already mounted try to umount first # - logging per syslog, see $SYSLOG # - +# CONFIGURATION +# ------------- # # Mountpoint, the same as in fstab @@ -75,22 +84,30 @@ EJECTWRONG=0 EJECTUMOUNT=0 # Log warnings/errors in syslog. 1 = yes, 0 = no. -SYSLOG=0 +SYSLOG=1 # Create a length.vdr after mounting the dvd for the played recording. 1 = yes, 0 = no. # Only for non-vfat and with index.vdr only on dvd. GETLENGTH=0 -# +# Put debug infos in file $DEBUGLOG. Only if $DEBUG=1. +DEBUG=0 +DEBUGLOG="/tmp/dvdarchive.sh-debug.log" +# +# # No changes needed after this mark +# Remove trailing slash MOUNTPOINT=${MOUNTPOINT/%\/} -DEVICE="$(awk '( $1 !~ /^#/ ) && ( $2 == "'$MOUNTPOINT'" ) { printf("%s", $1); exit; }' /etc/fstab)" # dvd-device, used by isodetect if exists +# determine dvd-device, used by eject and isodetect if exists +DEVICE="$(awk '( $1 !~ /^#/ ) && ( $2 == "'$MOUNTPOINT'" ) { printf("%s", $1); exit; }' /etc/fstab)" +ACTION="$1" REC="$2" NAME="$3" +# function to print help call() { echo -e "\nScript $0 needs three parameters for mount and two for umount. The first must be mount or umount, the second is the full path.\n" echo -e "Only for mounting the script needs a third parameter, the last part of the recording path.\n" @@ -99,8 +116,13 @@ call() { echo -e "For more information read the MANUAL part inside this script.\n" } +# function to log messages log() { - case $1 in + case "$1" in + info) + echo -e "INFO: $2" + [ $SYSLOG -eq 1 ] && logger -t "$0" "INFO: $2" + ;; warning) echo -e "WARNING: $2" [ $SYSLOG -eq 1 ] && logger -t "$0" "WARNING: $2" @@ -108,15 +130,29 @@ log() { error) echo -e "ERROR: $2" [ $SYSLOG -eq 1 ] && logger -t "$0" "ERROR: $2" + if [ $DEBUG -eq 1 ]; then + echo "-------" >> $DEBUGLOG + echo -e "Parameters: $ACTION $REC $NAME\n" >> $DEBUGLOG + echo -e "ERROR: $2\n\nMountpoint: $MOUNTPOINT\nDevice: $DEVICE\n" >> $DEBUGLOG + echo -e "Filesystem: $(stat -f -c %T "$REC")\n" >> $DEBUGLOG + mount >> $DEBUGLOG + echo >> $DEBUGLOG + cat /proc/mounts >> $DEBUGLOG + echo >> $DEBUGLOG + sudo -l >> $DEBUGLOG + fi ;; esac } -[ "$1" = "mount" -o "$1" = "umount" ] || { call; exit 10; } -[ -z "$2" ] && { call; exit 10; } -[ "$1" = mount -a -z "$3" ] && { call; exit 10; } +# Some checks before doing something +[ "$ACTION" = "mount" -o "$ACTION" = "umount" ] || { call; exit 10; } +[ -z "$REC" ] && { call; exit 10; } +[ "$ACTION" = mount -a -z "$NAME" ] && { call; exit 10; } +[ ! -d "$MOUNTPOINT" ] && { log error "Mountpoint $MOUNTPOINT doesn't exist"; exit 10; } +[ ! -e "$DEVICE" ] && { log error "Device $DEVICE doesn't exist"; exit 10; } -case "$1" in +case "$ACTION" in mount) # check if dvd is in drive, only if isodetect exists if [ -n "$(which isodetect)" -a -n "$DEVICE" ]; then @@ -131,12 +167,12 @@ mount) if mount | egrep -q " $MOUNTPOINT "; then # check if dvd is in use if mount | egrep -q "^$MOUNTPOINT"; then - log error "dvd in use" + log error "dvd in use (at: check if dvd is in use)" exit 1 fi # if already mountet, try to umount log warning "dvd already mounted, try to umount" - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + umount "$MOUNTPOINT" || { log error "dvd umount error (at: dvd already mounted, try to umount)"; exit 1; } # unlink broken existing links for LINK in "${REC}/"*.vdr; do if [ -L "$LINK" -a ! -s "$LINK" ]; then @@ -145,13 +181,13 @@ mount) done fi # mount dvd - mount "$MOUNTPOINT" || { log error "dvd mount error"; exit 1; } + mount "$MOUNTPOINT" || { log error "dvd mount error (at: mount dvd)"; exit 1; } # is mounted, find recording on dvd DIR="$(find "${MOUNTPOINT}/" -name "$NAME")" # if not found, umount if [ -z "$DIR" ]; then log error "wrong dvd in drive / recording not found on dvd" - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + umount "$MOUNTPOINT" || { log error "dvd umount error (at: wrong dvd in drive / recording not found on dvd)"; exit 1; } # If wanted, eject dvd [ $EJECTWRONG -eq 1 ] && { eject "$DEVICE"; } exit 3 @@ -160,7 +196,7 @@ mount) if [ "$(stat -f -c %T "$REC")" != "vfat" ]; then # link index.vdr if not exist if [ ! -e "${REC}/index.vdr" ]; then - cp -s "${DIR}/index.vdr" "${REC}/" + cp -s "${DIR}/index.vdr" "${REC}/" || { log error "could not link index.vdr (at: link index.vdr from dvd to disk)"; } fi # link [0-9]*.vdr files cp -s "${DIR}"/[0-9]*.vdr "${REC}/" @@ -168,7 +204,7 @@ mount) if [ $? -ne 0 ]; then log error "error while linking [0-9]*.vdr" # umount dvd bevor unlinking - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + umount "$MOUNTPOINT" || { log error "dvd umount error (at: error while linking)"; exit 1; } # unlink broken links for LINK in "${REC}/"*.vdr; do if [ -L "$LINK" -a ! -s "$LINK" ]; then @@ -184,25 +220,26 @@ mount) else if [ ! "$(sudo -l | egrep "\(root\) NOPASSWD: /bin/mount")" -o ! "$(sudo -l | egrep "\(root\) NOPASSWD: /bin/umount")" ]; then log error "you must configure sudo and allow $(whoami) to use mount/umount!" - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + log info "$(sudo -l)" + umount "$MOUNTPOINT" || { log error "dvd umount error (at: you must configure sudo)"; exit 1; } exit 5 fi # mount recording sudo mount --bind "$DIR" "$REC" if [ $? -ne 0 ]; then log error "sudo mount --bind $DIR $REC" - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + umount "$MOUNTPOINT" || { log error "dvd umount error (at: sudo mount --bind)"; exit 1; } exit 5 fi fi ;; umount) # check if dvd is mounted - mount | egrep -q " $MOUNTPOINT " || { log error "dvd not mounted"; exit 1; } + mount | egrep -q " $MOUNTPOINT " || { log error "dvd not mounted (at: check if dvd is mounted)"; exit 1; } # check if video partition is vfat if [ "$(stat -f -c %T "$REC")" != "vfat" ]; then # is mounted, umount dvd bevor unlinking - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + umount "$MOUNTPOINT" || { log error "dvd umount error (at: is mounted, umount dvd bevor unlinking)"; exit 1; } # unlink broken links for LINK in "${REC}/"*.vdr; do if [ -L "$LINK" -a ! -s "$LINK" ]; then @@ -212,15 +249,15 @@ umount) else # umount recording sudo umount "$REC" || { log error "sudo umount $REC"; exit 5; } - # umount dvd - umount "$MOUNTPOINT" || { log error "dvd umount error"; exit 1; } + # umount dvd at umount + umount "$MOUNTPOINT" || { log error "dvd umount error (at: umount dvd at umount)"; exit 1; } fi # If wanted, eject dvd [ $EJECTUMOUNT -eq 1 ] && { eject "$DEVICE"; } ;; *) # Output help - log error "\nWrong action." + log error "\nWrong action $ACTION." call ;; esac -- cgit v1.2.3