|
|
@ -1,18 +1,51 @@ |
|
|
|
#!/bin/sh /etc/rc.common |
|
|
|
# Copyright (C) 2014 OpenWrt.org |
|
|
|
|
|
|
|
NAME=upmpdcli |
|
|
|
START=95 |
|
|
|
|
|
|
|
create_user() { |
|
|
|
group_exists upmpdcli || group_add upmpdcli 89 |
|
|
|
user_exists upmpdcli || user_add upmpdcli 89 |
|
|
|
UPMPD_BIN=/usr/bin/${NAME} |
|
|
|
|
|
|
|
USE_PROCD=1 |
|
|
|
|
|
|
|
append_arg() { |
|
|
|
local cfg="$1" |
|
|
|
local var="$2" |
|
|
|
local opt="$3" |
|
|
|
local def="$4" |
|
|
|
local val |
|
|
|
|
|
|
|
config_get val "$cfg" "$var" |
|
|
|
[ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}" |
|
|
|
} |
|
|
|
|
|
|
|
start_instance() { |
|
|
|
local cfg="$1" |
|
|
|
local interface |
|
|
|
|
|
|
|
procd_open_instance |
|
|
|
|
|
|
|
procd_set_param command "${UPMPD_BIN}" |
|
|
|
|
|
|
|
# config_get interface "$cfg" interface |
|
|
|
# procd_add_reload_interface_trigger $interface |
|
|
|
|
|
|
|
append_arg "$cfg" interface "-i" |
|
|
|
append_arg "$cfg" mpd_host "-h" |
|
|
|
append_arg "$cfg" mpd_port "-p" |
|
|
|
append_arg "$cfg" upmpd_port "-P" |
|
|
|
|
|
|
|
append_arg "$cfg" config "-c" |
|
|
|
append_arg "$cfg" friendly_name "-f" |
|
|
|
|
|
|
|
procd_close_instance |
|
|
|
} |
|
|
|
|
|
|
|
start() { |
|
|
|
create_user |
|
|
|
service_start /usr/bin/upmpdcli -D |
|
|
|
service_triggers() { |
|
|
|
procd_add_reload_trigger "${NAME}" |
|
|
|
} |
|
|
|
|
|
|
|
stop() { |
|
|
|
service_stop /usr/bin/upmpdcli |
|
|
|
start_service() { |
|
|
|
config_load ${NAME} |
|
|
|
config_foreach start_instance ${NAME} |
|
|
|
} |