From fd04302f286b01cc4ca7ad039300ba3135a4a3bb Mon Sep 17 00:00:00 2001 From: nico Date: Wed, 16 Nov 2011 09:44:14 +0000 Subject: [PATCH] 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 --- multimedia/ushare/Makefile | 2 +- multimedia/ushare/files/ushare.config | 4 +- multimedia/ushare/files/ushare.init | 58 ++++++++++++++++----------- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/multimedia/ushare/Makefile b/multimedia/ushare/Makefile index 471f5cf5f..a85f64836 100644 --- a/multimedia/ushare/Makefile +++ b/multimedia/ushare/Makefile @@ -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/ diff --git a/multimedia/ushare/files/ushare.config b/multimedia/ushare/files/ushare.config index b220eb2da..d7d0dce18 100644 --- a/multimedia/ushare/files/ushare.config +++ b/multimedia/ushare/files/ushare.config @@ -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' diff --git a/multimedia/ushare/files/ushare.init b/multimedia/ushare/files/ushare.init index 457f582db..db661d198 100644 --- a/multimedia/ushare/files/ushare.init +++ b/multimedia/ushare/files/ushare.init @@ -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' } -