blob: 365344b00a5db6649ac2663ccd5a0070d5c917d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#!/bin/sh
set -u
set -e
#set this to your VDR video directory
#BASE_DIR=/srv/video.00
BASE_DIR=/srv/VDR_VIDEO
# record hook script to handle the protection.fsk record protection in case of
# the edited|move events
#
# there are two modes for the protection.fsk protection
# 1. the recording are direct protected with an protection.fsk flag file in the
# recording directory
# 2. the recording are indirect protected because an upper directory are
# protected with the protection.fsk
# this script will handle this as follow
# - if the record itself are protected the target record will also protected in
# the same way
# - if the record are protected because an upper directory are protected
# (indirect protection) then
# - the target record will not be direct protected if an upper directory of
# the target are protected, so the record keep its indirect protection status
# - the target record will be direct protected if none of the upper directory
# are protected
#
# ATTENTION! For "edited" this Script need the name of the original recording as
# the third Parameter.
# This is the case if you use vdr >= 1.7.28, but Plugins that call the recording
# "edited" hook need to support this also.
#
# If you found a bug please send me an message
#Copyright 2012 Keine_Ahnung@vdr-portal.de
#This script 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 3 of the License, or (at your option) any later version.
#This sCript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
#without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
#PURPOSE. See the GNU General Public License for more details.
#You should have received a copy of the GNU General Public License along with this script.
#If not, see http://www.gnu.org/licenses/.
################################################################################
PROTECTION_FILE="protection.fsk"
FSK_NOT=1
FSK_DIRECT=2
FSK_INDIRECT=3
check_protection() {
testdir="${1}"
# direct protection
[ -e "${testdir}/${PROTECTION_FILE}" ] && return ${FSK_DIRECT}
# indirect protection, "protection.fsk" in upper level directory
testdir="$(dirname "${testdir}")"
while [ "${testdir}" != "${BASE_DIR}" ]; do
[ -e "${testdir}/${PROTECTION_FILE}" ] && return ${FSK_INDIRECT}
testdir="$(dirname "${testdir}")"
# to be sure to not get in endless loop
if [ "${#testdir}" -lt "2" ]; then
printf "Something goes really wrong!\n" 1>&2
exit 1
fi
done
# no direct or indirect protection
return ${FSK_NOT}
}
do_protection() {
ret=0
check_protection "${SOURCE_RECORD_DIR}" || ret=$?
case "${ret}" in
${FSK_DIRECT})
# source protection are direct, so set direct protection again
if [ -d "${TARGET_RECORD_DIR}" ]; then
touch "${TARGET_RECORD_DIR}/${PROTECTION_FILE}"
else
printf "Target directory (\"%s\") not found!\n" "${TARGET_RECORD_DIR}" 1>&2
exit 1
fi
;;
${FSK_INDIRECT})
ret=0
check_protection "${TARGET_RECORD_DIR}" || ret=$?
if [ "${ret}" -ne "${FSK_INDIRECT}" ]; then
# source protection are indirect but no indirect protection in target
# dir, so change mode to direct protection
if [ -d "${TARGET_RECORD_DIR}" ]; then
touch "${TARGET_RECORD_DIR}/${PROTECTION_FILE}"
else
printf "Target directory (\"%s\") not found!\n" "${TARGET_RECORD_DIR}" 1>&2
exit 1
fi
fi
;;
esac
}
case "${1}" in
edited)
SOURCE_RECORD_DIR="${3}"
TARGET_RECORD_DIR="${2}"
do_protection
;;
move)
SOURCE_RECORD_DIR="${2}"
TARGET_RECORD_DIR="${3}"
do_protection
;;
esac
exit 0
|