From 06054c88a217d65b32a3bd53f8032eb772d3aed1 Mon Sep 17 00:00:00 2001 From: Thomas Maass Date: Mon, 21 Oct 2013 18:24:18 +0200 Subject: Added shellscript to archive an recording. Updated README. --- README | 26 +++++++++++++-- vdr_move_to_hdd.sh | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 vdr_move_to_hdd.sh diff --git a/README b/README index ae2cb39..b5529cc 100644 --- a/README +++ b/README @@ -2,14 +2,14 @@ This is a "plugin" for the Video Disk Recorder (VDR). Written by: Thomas Maass -Project's homepage: URL +Project's homepage: http://projects.vdr-developer.org/projects/plg-hddarchive -Latest version available at: URL +Latest version available at: http://projects.vdr-developer.org/projects/plg-hddarchive This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. +any later version. See the file COPYING for more information. Requirements @@ -19,3 +19,23 @@ Requirements Description: This plugin brings the archive-hdd functionality to VDR. +Install and start it like any other plugin. +The optional patch for VDR integrates the archive functionalities into +its original recordings menu. +There is also a patch for Skinnopacity to display an archive symbol. +The symbol isn't part of this patch. Just use an 48x48px image from your +desktop environment and copy it to skinnopacity/icons/skinIcons/archive.png. + +The script vdr_move_to_hdd.sh can be used with the reccmds.conf to archive +a recording. Change the mountpoint inside and use it with vdr-bg.sh or at: + +Archive?: /usr/local/bin/vdr-bg.sh /usr/local/bin/vdr_move_to_hdd.sh + +Make sure, that the vdr user has permissions to mount the archive-disk. Setup +/etc/fstab like this: + +/dev/sdb1 /media/archive-hdd auto defaults,user,noauto 0 0 + +To create an archive-disk, just format it and create a text file named "hdd" +in its root. Write the archive-id in this file (8 characters max. ). This +id is used to identify the archive-disk, so choose a unique one. diff --git a/vdr_move_to_hdd.sh b/vdr_move_to_hdd.sh new file mode 100644 index 0000000..3fd2e0d --- /dev/null +++ b/vdr_move_to_hdd.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +ARCHIVEHDD=/media/archive-hdd + +HDDMOUNTED=0 + +VID_FULLPATH="`cd \"$VIDEO\" 2>/dev/null && pwd || echo \"$VIDEO\"`/" + +SRC_FULLPATH="`cd \"$1\" 2>/dev/null && pwd || echo \"${1}\"`/" + +VIDPATH="`cd \"$1\" && cd \"..\" 2>/dev/null && pwd || echo \"${1}\"`/" + +PART1=${VIDPATH%*/} +PART1=${PART1##*/} + +PART2=${SRC_FULLPATH%*/} +PART2=${PART2##*/} + +MOVIEFOLDER=$PART1"/"$PART2"/" + +# Test, if recording has already moved? +if [ -f ${SRC_FULLPATH}/hdd.vdr ]; then + svdrpsend mesg "Recording has already been moved to Archive-HDD!" + exit 1 +fi + + +# Test, if Archive-HDD can be mounted +if [ ! -f ${ARCHIVEHDD}/hdd.vdr ]; then + mount ${ARCHIVEHDD} + HDDMOUNTED=1 +fi +if [ ! -f ${ARCHIVEHDD}/hdd.vdr ]; then + svdrpsend mesg "Archive-HDD could not be mounted!" + exit 1 +fi + +# Test if there is enough disk space on Archive-HDD +SIZE_SRC="`du $SRC_FULLPATH | cut -f 1`" +SIZE_DEST="`df -Pk /media/archive-hdd | tail -n 1 | tr -s ' ' | cut -d' ' -f 4`" + +if [ $SIZE_DEST -lt $SIZE_SRC ]; then + svdrpsend mesg "Not enough space on Archive-HDD!" + umount ${ARCHIVEHDD} + exit 1 +fi + +MODMOVIEFOLDER=$(echo "$MOVIEFOLDER" | awk ' +BEGIN{ + FS="/"; +} +{ + MODMOVIEFOLDER=""; + for (i=1; i<=NF; i++) { + if ((i==NF-2) && (index($i, "%")==1)) { # cutted movie + MODMOVIEFOLDER=MODMOVIEFOLDER "" substr ($i, 2); + } else { + MODMOVIEFOLDER=MODMOVIEFOLDER "" $i; + } + if (i