1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2015 OpenWrt.org
15 config_get val
"$cfg" "$var"
16 [ -n "$val" -o -n "$def" ] && echo -e "\t$opt = ${val:-$def};" >> $file
26 config_get val
"$cfg" "$var"
27 [ -n "$val" -o -n "$def" ] && echo -e "\t$opt = \"${val:-$def}\";" >> $file
32 local conf_custom conf_file aux
34 config_get_bool aux
"$cfg" 'disabled' '0'
35 [ "$aux" = 1 ] && return 1
37 config_get_bool conf_custom
"$cfg" 'conf_custom' '0'
38 config_get conf_file
"$cfg" "conf_file"
39 if [ $conf_custom -ne 1 ] && [ ! -n "$conf_file" ]; then
41 conf_file
="/var/etc/shairport-sync-${cfg}.conf"
43 echo -e "// Automatically generated from UCI config\n" > $conf_file
46 echo -e "general =" >> $conf_file
47 echo -e "{" >> $conf_file
48 append_str
"$cfg" "$conf_file" name
"name"
49 append_str
"$cfg" "$conf_file" password
"password"
50 append_str
"$cfg" "$conf_file" interpolation
"interpolation"
51 append_str
"$cfg" "$conf_file" output_backend
"output_backend"
52 append_str
"$cfg" "$conf_file" mdns_backend
"mdns_backend"
53 append_num
"$cfg" "$conf_file" port
"port"
54 append_num
"$cfg" "$conf_file" udp_port_base
"udp_port_base"
55 append_num
"$cfg" "$conf_file" udp_port_range
"udp_port_range"
56 append_str
"$cfg" "$conf_file" statistics
"statistics"
57 append_num
"$cfg" "$conf_file" drift
"drift"
58 append_num
"$cfg" "$conf_file" resync_threshold
"resync_threshold"
59 append_num
"$cfg" "$conf_file" log_verbosity
"log_verbosity"
60 append_str
"$cfg" "$conf_file" ignore_volume_control
"ignore_volume_control"
61 append_num
"$cfg" "$conf_file" volume_range_db
"volume_range_db"
62 echo -e "};\n" >> $conf_file
65 echo -e "latencies =" >> $conf_file
66 echo -e "{" >> $conf_file
67 append_num
"$cfg" "$conf_file" latencies_default
"default"
68 append_num
"$cfg" "$conf_file" latencies_itunes
"itunes"
69 append_num
"$cfg" "$conf_file" latencies_airplay
"airplay"
70 append_num
"$cfg" "$conf_file" latencies_forked_daapd
"forkedDaapd"
71 echo -e "};\n" >> $conf_file
74 echo -e "metadata =" >> $conf_file
75 echo -e "{" >> $conf_file
76 append_str
"$cfg" "$conf_file" metadata_enabled
"enabled"
77 append_str
"$cfg" "$conf_file" metadata_cover_art
"include_cover_art"
78 append_str
"$cfg" "$conf_file" metadata_pipe_name
"pipe_name"
79 echo -e "};\n" >> $conf_file
82 echo -e "sessioncontrol =" >> $conf_file
83 echo -e "{" >> $conf_file
84 append_str
"$cfg" "$conf_file" sesctl_run_before_play_begins
"run_this_before_play_begins"
85 append_str
"$cfg" "$conf_file" sesctl_run_after_play_ends
"run_this_after_play_ends"
86 append_str
"$cfg" "$conf_file" sesctl_wait_for_completion
"wait_for_completion"
87 append_str
"$cfg" "$conf_file" sesctl_session_interruption
"allow_session_interruption"
88 append_num
"$cfg" "$conf_file" sesctl_session_timeout
"session_timeout"
89 echo -e "};\n" >> $conf_file
92 echo -e "alsa =" >> $conf_file
93 echo -e "{" >> $conf_file
94 append_str
"$cfg" "$conf_file" alsa_output_device
"output_device"
95 append_str
"$cfg" "$conf_file" alsa_mixer_control_name
"mixer_control_name"
96 append_str
"$cfg" "$conf_file" alsa_mixer_device
"mixer_device"
97 append_num
"$cfg" "$conf_file" alsa_latency_offset
"audio_backend_latency_offset"
98 append_num
"$cfg" "$conf_file" alsa_buffer_length
"audio_backend_buffer_desired_length"
99 echo -e "};\n" >> $conf_file
101 # Pipe audio back end
102 echo -e "pipe =" >> $conf_file
103 echo -e "{" >> $conf_file
104 append_str
"$cfg" "$conf_file" pipe_name
"name"
105 append_num
"$cfg" "$conf_file" pipe_latency_offset
"audio_backend_latency_offset"
106 append_num
"$cfg" "$conf_file" pipe_buffer_length
"audio_backend_buffer_desired_length"
107 echo -e "};\n" >> $conf_file
109 # Stdout audio back end
110 echo -e "stdout =" >> $conf_file
111 echo -e "{" >> $conf_file
112 append_num
"$cfg" "$conf_file" stdout_latency_offset
"audio_backend_latency_offset"
113 append_num
"$cfg" "$conf_file" stdout_buffer_length
"audio_backend_buffer_desired_length"
114 echo -e "};\n" >> $conf_file
119 procd_set_param
command /usr
/bin
/shairport-sync
120 procd_append_param
command -c $conf_file
122 config_get_bool aux
"$cfg" 'respawn' '0'
123 [ "$aux" = 1 ] && procd_set_param respawn
129 procd_add_reload_trigger
"shairport-sync"
133 config_load shairport-sync
134 config_foreach start_instance shairport-sync