blob: 02644480162faa16bfff2b401dca257f1ad64ff6 (
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
|
# $Id$
include language-functions
# merging the files under /etc/vdr/commands/ to one single file under /var/vdr/merged-config-files/ and links
# it to /etc/vdr/commands.conf.
# This merged file can then be used by the vdr process.
merge_commands_conf() {
[[ -z ${VDR_LANGUAGE} ]] && read_vdr_language
local CONFIG="${CONFIG:-/etc/vdr}"
local sdir="${1}"
local destfile="${2}"
local order="${3}"
local bname=${destfile##*/}
local mergedfile="/var/vdr/merged-config-files/${bname}"
# merging files
if [[ -f "${mergedfile}" ]]; then
if ! rm "${mergedfile}"; then
ewarn " Could not change ${mergedfile}"
return
fi
fi
cat > "${mergedfile}" <<-EOT
# Autogenerated ${destfile}
# Warning: Do not change this file.
# This file is generated automatically by /etc/init.d/vdr.
# Change the source files under ${sdir}.
EOT
test -d "${sdir}" || return 1
SFILES=$(echo ${sdir}/*.conf)
local f
local inputf
for f in ${SFILES}; do
[[ -f "${f}" ]] || continue
inputf="${f}"
[[ -f "${f}.${VDR_LANGUAGE}" ]] && inputf="${f}.${VDR_LANGUAGE}"
echo "# source : ${inputf}" >> "${mergedfile}"
cat "${inputf}" >> "${mergedfile}"
echo >> "${mergedfile}"
done
chown vdr:vdr "${mergedfile}"
# link it to real location
if [[ -L "${destfile}" ]]; then
# remove link
rm "${destfile}"
else
# no link
if [[ -f "${destfile}" ]]; then
mv "${destfile}" "${destfile}.backup"
einfo " Saved original ${destfile} as ${destfile}.backup"
fi
fi
ln -s "${mergedfile}" "${destfile}"
}
#Usage example
# merge_commands_conf /etc/vdr/commands /etc/vdr/commands.conf "${ORDER_COMMANDS}"
# merge_commands_conf /etc/vdr/reccmds /etc/vdr/reccmds.conf "${ORDER_RECCMDS}"
|