Changeset 29092


Ignore:
Timestamp:
2011-11-14T03:38:38+01:00 (6 years ago)
Author:
nico
Message:

packages/siproxd: use new service functions, create pid-file in /var/run/siproxd owned by nobody:nogroup

Location:
packages/net/siproxd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • packages/net/siproxd/Makefile

    r28097 r29092  
    1010PKG_NAME:=siproxd 
    1111PKG_VERSION:=0.8.1 
    12 PKG_RELEASE:=2 
     12PKG_RELEASE:=3 
     13 
    1314PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 
    1415PKG_SOURCE_URL:=@SF/siproxd 
  • packages/net/siproxd/files/siproxd.init

    r28097 r29092  
    44 
    55START=50 
     6 
     7SERVICE_USE_PID=1 
     8 
    69siproxd_bin="/usr/sbin/siproxd" 
    7 siproxd_conf_dir="/var/etc/" 
    8 siproxd_conf_prefix="$siproxd_conf_dir"siproxd- 
    9 siproxd_registration_dir="/var/lib/siproxd/" 
    10 siproxd_pid_dir="/var/run/" 
     10siproxd_conf_dir="/var/etc" 
     11siproxd_conf_prefix="$siproxd_conf_dir/siproxd-" 
     12siproxd_registration_dir="/var/lib/siproxd" 
     13siproxd_pid_dir="/var/run/siproxd" 
    1114 
    1215deal_with_lists () { 
    13         echo "$2" = "$1" >> "$siproxd_conf_prefix$cfg"                           
    14 } 
    15  
    16 start_instance() 
    17 { 
     16        echo "$2" = "$1" >> "$siproxd_conf_prefix$cfg" 
     17} 
     18 
     19start_instance() { 
    1820        local cfg="$1" 
     21 
    1922        config_get if_inbound "$cfg" if_inbound 
    2023        config_get if_outbound "$cfg" if_outbound 
     
    2831        config_get user "$cfg" user nobody 
    2932        config_get chrootjail "$cfg" chrootjail 
    30         config_get registration_file "$cfg" registration_file "$siproxd_registration_dir"siproxd_registrations-"$cfg" 
     33        config_get registration_file "$cfg" registration_file "$siproxd_registration_dir/siproxd_registrations-$cfg" 
    3134        config_get autosave_registrations "$cfg" autosave_registrations 300 
    32         config_get pid_file "$cfg" pid_file "$siproxd_pid_dir"siproxd-"$cfg".pid 
     35        config_get pid_file "$cfg" pid_file "$siproxd_pid_dir/siproxd-$cfg.pid" 
    3336        config_get_bool rtp_proxy_enable "$cfg" rtp_proxy_enable 1 
    3437        config_get rtp_port_low "$cfg" rtp_port_low 7070 
     
    5861        config_get outbound_domain_port "$cfg" outbound_domain_port 
    5962 
    60         if [ ! -d "$siproxd_conf_dir" ]; then 
    61                 mkdir -p "$siproxd_conf_dir" 
    62                 chmod 0755 "$siproxd_conf_dir" 
    63         fi 
    6463        if [ -f "$siproxd_conf_prefix$cfg" ]; then 
    6564                rm "$siproxd_conf_prefix$cfg" 
     
    9493                echo chrootjail = "$chrootjail" >> "$siproxd_conf_prefix$cfg" 
    9594        fi 
    96         if [ ! -d "$siproxd_registration_dir" ]; then 
    97                 mkdir -p "$siproxd_registration_dir" 
    98                 chmod 0755 "$siproxd_registration_dir" 
    99         fi 
    10095        echo registration_file = "$registration_file" >> "$siproxd_conf_prefix$cfg" 
    10196        echo autosave_registrations = "$autosave_registrations" >> "$siproxd_conf_prefix$cfg" 
    102         if [ ! -d "$siproxd_pid_dir" ]; then 
    103                 mkdir -p "$siproxd_pid_dir" 
    104                 chmod 0755 "$siproxd_pid_dir" 
    105         fi 
     97 
    10698        echo pid_file = "$pid_file" >> "$siproxd_conf_prefix$cfg" 
    10799        echo rtp_proxy_enable = "$rtp_proxy_enable" >> "$siproxd_conf_prefix$cfg" 
     
    212204        config_list_foreach "$cfg" 'plugin_regex_replace' deal_with_lists "plugin_regex_replace" 
    213205 
    214         $siproxd_bin --config "$siproxd_conf_prefix$cfg" 
    215 } 
    216  
    217 stop_instance() 
    218 { 
     206        SERVICE_PID_FILE="$pid_file" \ 
     207        service_start $siproxd_bin --config "$siproxd_conf_prefix$cfg" 
     208} 
     209 
     210stop_instance() { 
    219211        local cfg="$1" 
    220212 
    221         [ -f "$siproxd_pid_dir"siproxd-"$cfg".pid ] && { 
    222                 start-stop-daemon -K -q -n ${siproxd_bin##*/} \ 
    223                         -p "$siproxd_pid_dir"siproxd-"$cfg".pid -s TERM 
    224  
    225                 rm "$siproxd_pid_dir"siproxd-"$cfg".pid 
     213        config_get pid_file "$cfg" pid_file "$siproxd_pid_dir/siproxd-$cfg.pid" 
     214 
     215        SERVICE_PID_FILE="$pid_file" \ 
     216        service_stop $siproxd_bin 
     217} 
     218 
     219start() { 
     220        mkdir -m 0755 -p "$siproxd_conf_dir" 
     221        mkdir -m 0755 -p "$siproxd_registration_dir" 
     222        [ -d "$siproxd_pid_dir" ] || { 
     223                mkdir -m 0755 -p "$siproxd_pid_dir" 
     224                chmod 0750 "$siproxd_pid_dir" 
     225                chown nobody:nogroup "$siproxd_pid_dir" 
    226226        } 
    227 } 
    228  
    229 start() { 
    230         config_load siproxd 
    231         config_foreach start_instance siproxd 
     227 
     228        config_load 'siproxd' 
     229        config_foreach start_instance 'siproxd' 
    232230} 
    233231 
    234232stop() { 
    235         config_load siproxd 
    236         config_foreach stop_instance siproxd 
    237         # for case when pid file was not written 
    238         # because of permission issues 
    239         pkill ${siproxd_bin##*/} 
    240 } 
     233        config_load 'siproxd' 
     234        config_foreach stop_instance 'siproxd' 
     235} 
Note: See TracChangeset for help on using the changeset viewer.