Changeset 29174


Ignore:
Timestamp:
2011-11-16T10:44:14+01:00 (5 years ago)
Author:
nico
Message:

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

Location:
packages/multimedia/ushare
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • packages/multimedia/ushare/Makefile

    r28714 r29174  
    1010PKG_NAME:=ushare 
    1111PKG_VERSION:=1.1a 
    12 PKG_RELEASE:=2 
     12PKG_RELEASE:=3 
    1313 
    1414PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 
  • packages/multimedia/ushare/files/ushare.config

    r12691 r29174  
    11config 'ushare' 
    2         option 'username' 'nobody' 
     2        option 'enabled' '0' 
     3        option 'user' 'nobody' 
    34        option 'servername' 'OpenWrt' 
    45        option 'interface' 'br-lan' 
     
    78        option 'disable_telnet' '1' 
    89        option 'disable_webif' '1' 
    9         option 'enabled' '0' 
  • packages/multimedia/ushare/files/ushare.init

    r28714 r29174  
    33START=50 
    44 
    5 BIN=/usr/bin/ushare 
    6 SSD=start-stop-daemon 
     5SERVICE_DAEMONIZE=1 
     6SERVICE_WRITE_PID=1 
    77 
    88append_bool() { 
     
    2424} 
    2525 
    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} & 
     26section_enabled() { 
     27        config_get_bool enabled "$1" 'enabled' 0 
     28        [ $enabled -gt 0 ] 
    3929} 
    4030 
    41 stop_service() { 
     31start_instance() { 
    4232        local section="$1" 
     33 
     34        section_enabled "$section" || return 1 
     35 
    4336        args="" 
    44         config_get username             "$section" "username" 
     37        config_get uid "$section" 'user' 
     38        config_get servername "$section" 'servername' 
     39        config_get interface "$section" 'interface' 
     40        config_get options "$section" 'options' 
     41        config_get content_directories "$section" 'content_directories' 
     42        append_bool "$section" 'disable_webif' '-w' 
     43        append_bool "$section" 'disable_telnet' '-t' 
    4544 
    46         $SSD -K -x $BIN -c ${username:-nobody} -s 2 -p /var/run/ushare.pid 
     45        SERVICE_UID="$uid" \ 
     46        service_start /usr/bin/ushare -n "${servername:-OpenWrt}" -i "${interface:-br-lan}" -c "${content_directories:-/tmp}" $args ${options} 
     47} 
     48 
     49stop_instance() { 
     50        local section="$1" 
     51 
     52        section_enabled "$section" || return 1 
     53 
     54        config_get uid "$section" "user" 
     55 
     56        SERVICE_UID="$uid" \ 
     57        service_stop /usr/bin/ushare 
    4758} 
    4859 
    4960start() { 
    50         config_load ushare 
    51         config_foreach start_service ushare 
     61        config_load 'ushare' 
     62        config_foreach start_instance 'ushare' 
    5263} 
    5364 
    5465stop() { 
    55         config_load ushare 
    56         config_foreach stop_service ushare 
     66        config_load 'ushare' 
     67        config_foreach stop_instance 'ushare' 
    5768} 
    58  
Note: See TracChangeset for help on using the changeset viewer.