tiff: moved to github
[openwrt.org/packages.git] / multimedia / shairport.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2013-2014 OpenWrt.org
3
4 START=50
5 USE_PROCD=1
6
7 config_shairport() {
8 local cfg="$1"
9
10 local cfg_name
11 local cfg_password
12 local cfg_port
13 local cfg_buffer
14 local cfg_log
15 local cfg_cmd_start
16 local cfg_cmd_stop
17 local cfg_cmd_wait
18 local cfg_audio_output
19 local cfg_mdns
20
21 config_get cfg_name $cfg 'name' 'AirPort'
22 config_get cfg_password $cfg 'password' ''
23 config_get cfg_port $cfg 'port' '5002'
24 config_get cfg_buffer $cfg 'buffer' '256'
25 config_get cfg_log $cfg 'log' '/var/log/shairport'
26 config_get cfg_cmd_start $cfg 'cmd_start' ''
27 config_get cfg_cmd_stop $cfg 'cmd_stop' ''
28 config_get_bool cfg_cmd_wait $cfg 'cmd_wait' '0'
29 config_get cfg_audio_output $cfg 'audio_output' ''
30 config_get cfg_mdns $cfg 'mdns' ''
31
32 procd_open_instance
33
34 procd_set_param command /usr/sbin/shairport
35 procd_append_param command -a "$cfg_name"
36 [ ! -z "$cfg_password" ] && procd_append_param command -k "$cfg_password"
37 procd_append_param command -p $cfg_port
38 procd_append_param command -b $cfg_buffer
39 procd_append_param command -l $cfg_log
40 [ ! -z "$cfg_cmd_start" ] && procd_append_param command -B "$cfg_cmd_start"
41 [ ! -z "$cfg_cmd_stop" ] && procd_append_param command -E "$cfg_cmd_stop"
42 [ "$cfg_cmd_wait" -eq 1 ] && procd_append_param command -w
43 [ ! -z "$cfg_audio_output" ] && procd_append_param command -o "$cfg_audio_output"
44 [ ! -z "$cfg_mdns" ] && procd_append_param command -m "$cfg_mdns"
45
46 procd_set_param respawn
47 procd_close_instance
48 }
49
50 start_service() {
51 config_load shairport
52 config_foreach config_shairport shairport
53 }
54
comments