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_NAME:=ushare
PKG_VERSION:=1.1a PKG_VERSION:=1.1a
PKG_RELEASE:=2 PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://ushare.geexbox.org/releases/ PKG_SOURCE_URL:=http://ushare.geexbox.org/releases/

View File

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

View File

@ -2,8 +2,8 @@
# Copyright (C) 2008 OpenWrt.org # Copyright (C) 2008 OpenWrt.org
START=50 START=50
BIN=/usr/bin/ushare SERVICE_DAEMONIZE=1
SSD=start-stop-daemon SERVICE_WRITE_PID=1
append_bool() { append_bool() {
local section="$1" local section="$1"
@ -23,36 +23,46 @@ append_string() {
[ -n "$_val" ] && append args "$3 $_val" [ -n "$_val" ] && append args "$3 $_val"
} }
start_service() { section_enabled() {
local section="$1" config_get_bool enabled "$1" 'enabled' 0
args="" [ $enabled -gt 0 ]
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} &
} }
stop_service() { start_instance() {
local section="$1" 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() { start() {
config_load ushare config_load 'ushare'
config_foreach start_service ushare config_foreach start_instance 'ushare'
} }
stop() { stop() {
config_load ushare config_load 'ushare'
config_foreach stop_service ushare config_foreach stop_instance 'ushare'
} }