1 #!/bin/sh /etc/rc.common
7 PROG=/usr/bin/tvheadend
9 TEMP_CONFIG=/tmp/tvheadend
10 PERSISTENT_CONFIG=/etc/tvheadend
13 "$PROG" -c "$1" -B -C -A >/dev/null 2>&1
16 ensure_config_exists() {
20 config_get config_path service config_path
22 if [ -z "$config_path" ]; then
23 [ -d "$PERSISTENT_CONFIG" ] || execute_first_run "$PERSISTENT_CONFIG"
25 # if the configuration directory is empty, empty config with grant-all ACL is created
26 [ -d "$config_path" ] && [ "$(ls -A $config_path)" ] || execute_first_run "$config_path"
29 # if use_temp_epgdb is enabled (default), most of the config is put to config_path
30 # (or /etc/config), except for epgdb.v2, which grows quite large and is write-heavy,
31 # so it's put into volatile tmpfs
32 # epgdb.v2 is created and symlinked to main config dir upon each start (if it doesn't exist)
33 config_get_bool use_temp_epgdb service use_temp_epgdb 1
34 if [ "$use_temp_epgdb" == "1" ]; then
35 TEMP_EPG="${TEMP_CONFIG}/epgdb.v2"
36 [ ! -f "$TEMP_EPG" ] && mkdir -p "$TEMP_CONFIG" && touch "$TEMP_EPG" && chmod 700 "$TEMP_EPG"
37 [ -z "$config_path" ] && config_path="$PERSISTENT_CONFIG"
38 ln -sf "$TEMP_EPG" "${config_path}/epgdb.v2"
44 config_get config_path service config_path "$PERSISTENT_CONFIG"
45 [ -n "$config_path" ] && procd_append_param command -c "$config_path"
46 config_get_bool nosyslog service nosyslog 0
47 [ "$nosyslog" -eq 1 ] && procd_append_param command --nosyslog
48 config_get_bool ipv6 server ipv6 0
49 [ "$ipv6" -eq 1 ] && procd_append_param command --ipv6
50 config_get bindaddr server bindaddr
51 [ -n "$bindaddr" ] && procd_append_param command --bindaddr "$bindaddr"
52 config_get http_port server http_port
53 [ -n "$http_port" ] && procd_append_param command --http_port "$http_port"
54 config_get http_root server http_root
55 [ -n "$http_root" ] && procd_append_param command --http_root "$http_root"
56 config_get htsp_port server htsp_port
57 [ -n "$htsp_port" ] && procd_append_param command --htsp_port "$htsp_port"
58 config_get htsp_port2 server htsp_port2
59 [ -n "$htsp_port2" ] && procd_append_param command --htsp_port "$htsp_port2"
60 config_get xspf server xspf 0
61 [ "$xspf" -eq 1 ] && procd_append_param command --xspf
67 procd_set_param file /etc/config/tvheadend
68 procd_set_param command "$PROG" -B