packages/ushare: use new service functions, change 'enable' option to 'enabled' like most other services are using, change 'username' option to 'user'

git-svn-id: svn://svn.openwrt.org/openwrt/packages@29174 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nico 2011-11-16 09:44:14 +00:00
parent e59863de27
commit fd04302f28
3 changed files with 37 additions and 27 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=ushare
PKG_VERSION:=1.1a
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://ushare.geexbox.org/releases/

View File

@ -1,9 +1,9 @@
config 'ushare'
option 'username' 'nobody'
option 'enabled' '0'
option 'user' 'nobody'
option 'servername' 'OpenWrt'
option 'interface' 'br-lan'
option 'options' ''
option 'content_directories' '/tmp'
option 'disable_telnet' '1'
option 'disable_webif' '1'
option 'enabled' '0'

View File

@ -2,8 +2,8 @@
# Copyright (C) 2008 OpenWrt.org
START=50
BIN=/usr/bin/ushare
SSD=start-stop-daemon
SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1
append_bool() {
local section="$1"
@ -23,36 +23,46 @@ append_string() {
[ -n "$_val" ] && append args "$3 $_val"
}
start_service() {
local section="$1"
args=""
config_get username "$section" "username"
config_get servername "$section" "servername"
config_get interface "$section" "interface"
config_get options "$section" "options"
config_get content_directories "$section" "content_directories"
append_bool "$section" "disable_webif" "-w"
append_bool "$section" "disable_telnet" "-t"
config_get_bool "enabled" "$section" "enabled" '1'
[ "$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} &
section_enabled() {
config_get_bool enabled "$1" 'enabled' 0
[ $enabled -gt 0 ]
}
stop_service() {
start_instance() {
local section="$1"
args=""
config_get username "$section" "username"
$SSD -K -x $BIN -c ${username:-nobody} -s 2 -p /var/run/ushare.pid
section_enabled "$section" || return 1
args=""
config_get uid "$section" 'user'
config_get servername "$section" 'servername'
config_get interface "$section" 'interface'
config_get options "$section" 'options'
config_get content_directories "$section" 'content_directories'
append_bool "$section" 'disable_webif' '-w'
append_bool "$section" 'disable_telnet' '-t'
SERVICE_UID="$uid" \
service_start /usr/bin/ushare -n "${servername:-OpenWrt}" -i "${interface:-br-lan}" -c "${content_directories:-/tmp}" $args ${options}
}
stop_instance() {
local section="$1"
section_enabled "$section" || return 1
config_get uid "$section" "user"
SERVICE_UID="$uid" \
service_stop /usr/bin/ushare
}
start() {
config_load ushare
config_foreach start_service ushare
config_load 'ushare'
config_foreach start_instance 'ushare'
}
stop() {
config_load ushare
config_foreach stop_service ushare
config_load 'ushare'
config_foreach stop_instance 'ushare'
}