[packages] ushare: quote server name (#10322)
[openwrt/svn-archive/archive.git] / multimedia / ushare / files / ushare.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008 OpenWrt.org
3 START=50
4
5 BIN=/usr/bin/ushare
6 SSD=start-stop-daemon
7
8 append_bool() {
9 local section="$1"
10 local option="$2"
11 local value="$3"
12 local _val
13 config_get_bool _val "$section" "$option" '0'
14 [ "$_val" -gt 0 ] && append args "$3"
15 }
16
17 append_string() {
18 local section="$1"
19 local option="$2"
20 local value="$3"
21 local _val
22 config_get _val "$section" "$option"
23 [ -n "$_val" ] && append args "$3 $_val"
24 }
25
26 start_service() {
27 local section="$1"
28 args=""
29 config_get username "$section" "username"
30 config_get servername "$section" "servername"
31 config_get interface "$section" "interface"
32 config_get options "$section" "options"
33 config_get content_directories "$section" "content_directories"
34 append_bool "$section" "disable_webif" "-w"
35 append_bool "$section" "disable_telnet" "-t"
36 config_get_bool "enabled" "$section" "enabled" '1'
37
38 [ "$enabled" -gt 0 ] && $SSD -x $BIN -c ${username:-nobody} -S -b -p /var/run/ushare.pid -m -- -n "${servername:-OpenWrt}" -i ${interface:-br-lan} -c ${content_directories:-/tmp} $args ${options} &
39 }
40
41 stop_service() {
42 local section="$1"
43 args=""
44 config_get username "$section" "username"
45
46 $SSD -K -x $BIN -c ${username:-nobody} -s 2 -p /var/run/ushare.pid
47 }
48
49 start() {
50 config_load ushare
51 config_foreach start_service ushare
52 }
53
54 stop() {
55 config_load ushare
56 config_foreach stop_service ushare
57 }
58