lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

tvheadend.init (2484B)


      1 #!/bin/sh /etc/rc.common
      2 
      3 START=99
      4 STOP=00
      5 
      6 USE_PROCD=1
      7 PROG=/usr/bin/tvheadend
      8 
      9 TEMP_CONFIG=/tmp/tvheadend
     10 PERSISTENT_CONFIG=/etc/tvheadend
     11 
     12 execute_first_run() {
     13 	"$PROG" -c "$1" -B -C -A >/dev/null 2>&1
     14 }
     15 
     16 ensure_config_exists() {
     17 	local config_path
     18 
     19 	config_load tvheadend
     20 	config_get config_path service config_path
     21 
     22 	if [ -z "$config_path" ]; then
     23 		[ -d "$PERSISTENT_CONFIG" ] || execute_first_run "$PERSISTENT_CONFIG"
     24 	else
     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"
     27 	fi
     28 
     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"
     39 	fi
     40 }
     41 
     42 load_uci_config() {
     43 	config_load tvheadend
     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
     62 }
     63 
     64 start_service() {
     65 	ensure_config_exists
     66 	procd_open_instance
     67 	procd_set_param file /etc/config/tvheadend
     68 	procd_set_param command "$PROG" -B
     69 	load_uci_config
     70 	procd_close_instance
     71 }