1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2015-2016 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 append_str
"$cfg" "$conf_file" regtype
"regtype"
63 echo -e "};\n" >> $conf_file
66 echo -e "metadata =" >> $conf_file
67 echo -e "{" >> $conf_file
68 append_str
"$cfg" "$conf_file" metadata_enabled
"enabled"
69 append_str
"$cfg" "$conf_file" metadata_cover_art
"include_cover_art"
70 append_str
"$cfg" "$conf_file" metadata_pipe_name
"pipe_name"
71 echo -e "};\n" >> $conf_file
74 echo -e "sessioncontrol =" >> $conf_file
75 echo -e "{" >> $conf_file
76 append_str
"$cfg" "$conf_file" sesctl_run_before_play_begins
"run_this_before_play_begins"
77 append_str
"$cfg" "$conf_file" sesctl_run_after_play_ends
"run_this_after_play_ends"
78 append_str
"$cfg" "$conf_file" sesctl_wait_for_completion
"wait_for_completion"
79 append_str
"$cfg" "$conf_file" sesctl_session_interruption
"allow_session_interruption"
80 append_num
"$cfg" "$conf_file" sesctl_session_timeout
"session_timeout"
81 echo -e "};\n" >> $conf_file
84 echo -e "alsa =" >> $conf_file
85 echo -e "{" >> $conf_file
86 append_str
"$cfg" "$conf_file" alsa_output_device
"output_device"
87 append_str
"$cfg" "$conf_file" alsa_mixer_control_name
"mixer_control_name"
88 append_str
"$cfg" "$conf_file" alsa_mixer_device
"mixer_device"
89 append_num
"$cfg" "$conf_file" alsa_latency_offset
"audio_backend_latency_offset"
90 append_num
"$cfg" "$conf_file" alsa_buffer_length
"audio_backend_buffer_desired_length"
91 append_str
"$cfg" "$conf_file" alsa_disable_synchronization
"disable_synchronization"
92 append_num
"$cfg" "$conf_file" alsa_period_size
"period_size"
93 append_num
"$cfg" "$conf_file" alsa_buffer_size
"buffer_size"
94 echo -e "};\n" >> $conf_file
97 echo -e "pipe =" >> $conf_file
98 echo -e "{" >> $conf_file
99 append_str
"$cfg" "$conf_file" pipe_name
"name"
100 append_num
"$cfg" "$conf_file" pipe_latency_offset
"audio_backend_latency_offset"
101 append_num
"$cfg" "$conf_file" pipe_buffer_length
"audio_backend_buffer_desired_length"
102 echo -e "};\n" >> $conf_file
104 # Stdout audio back end
105 echo -e "stdout =" >> $conf_file
106 echo -e "{" >> $conf_file
107 append_num
"$cfg" "$conf_file" stdout_latency_offset
"audio_backend_latency_offset"
108 append_num
"$cfg" "$conf_file" stdout_buffer_length
"audio_backend_buffer_desired_length"
109 echo -e "};\n" >> $conf_file
112 echo -e "ao =" >> $conf_file
113 echo -e "{" >> $conf_file
114 append_num
"$cfg" "$conf_file" ao_latency_offset
"audio_backend_latency_offset"
115 append_num
"$cfg" "$conf_file" ao_buffer_length
"audio_backend_buffer_desired_length"
116 echo -e "};\n" >> $conf_file
121 procd_set_param
command /usr
/bin
/shairport-sync
122 procd_append_param
command -c $conf_file
124 config_get_bool aux
"$cfg" 'respawn' '0'
125 [ "$aux" = 1 ] && procd_set_param respawn
131 procd_add_reload_trigger
"shairport-sync"
135 config_load shairport-sync
136 config_foreach start_instance shairport-sync