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

packages/softflowd: use new service functions, use softflowctl to stop softflowd via control socket

File:
1 edited

Legend:

Unmodified
Added
Removed
  • packages/net/softflowd/files/softflowd.init

    r9596 r29100  
    11#!/bin/sh /etc/rc.common 
    2 # Copyright (C) 2007 OpenWrt.org 
     2# Copyright (C) 2007-2011 OpenWrt.org 
     3 
    34START=50 
    4  
    5 NAME=softflowd 
    6 BIN_F=/usr/sbin/$NAME 
    7 SSD=start-stop-daemon 
    85 
    96append_bool() { 
     
    2522} 
    2623 
    27 start_service() { 
     24start_instance() { 
    2825        local section="$1" 
     26 
     27        config_get_bool enabled "$section" 'enabled' '0' 
     28        [ $enabled -gt 0 ] || return 1 
     29 
     30        config_get pid_file "$section" 'pid_file' 
     31 
    2932        args="" 
     33        append_string "$section" 'interface' '-i' 
     34        append_string "$section" 'pcap_file' '-r' 
     35        append_string "$section" 'timeout' '-t' 
     36        append_string "$section" 'max_flows' '-m' 
     37        append_string "$section" 'host_port' '-n' 
     38        append_string "$section" 'pid_file' '-p' 
     39        append_string "$section" 'control_socket' '-c' 
     40        append_string "$section" 'export_version' '-v' 
     41        append_string "$section" 'hoplimit' '-L' 
     42        append_string "$section" 'tracking_level' '-T' 
     43        append_bool "$section" track_ipv6 '-6' 
    3044 
    31         append_string "$section" interface "-i" 
    32         append_string "$section" pcap_file "-r" 
    33         append_string "$section" timeout "-t" 
    34         append_string "$section" max_flows "-m" 
    35         append_string "$section" host_port "-n" 
    36         append_string "$section" pid_file "-p" 
    37         append_string "$section" control_socket "-c" 
    38         append_string "$section" export_version "-v" 
    39         append_string "$section" hoplimit "-L" 
    40         append_string "$section" tracking_level "-T" 
    41         append_bool "$section" track_ipv6 "-6" 
    42         config_get_bool "enabled" "$section" "enabled" '1' 
    43         [ "$enabled" -gt 0 ] && $BIN_F $args 
     45        SERVICE_PID_FILE="$pid_file" \ 
     46        service_start /usr/sbin/softflowd $args${pid_file:+ -p $pid_file} 
    4447} 
    4548 
    46 stop_service() { 
     49stop_instance() { 
    4750        local section="$1" 
    48         config_get pidfile "$section" pid_file 
    49         config_get control_socket "$section" control_socket 
    5051 
    51         [ -n "$pid_file" ] || pid_file="$pidfile" 
    52         # FIXME 
    53         $SSD -K -p $pid_file -q && rm -f $control_socket 
     52        config_get_bool enabled "$section" 'enabled' '0' 
     53        [ $enabled -gt 0 ] || return 1 
     54 
     55        config_get control_socket "$section" 'control_socket' 
     56 
     57        [ -n "control_socket" -a -S $control_socket ] && { 
     58                /usr/sbin/softflowctl -c $control_socket exit 
     59        } 
    5460} 
    5561 
    5662start() { 
    57         mkdir -p /var/empty 
     63        mkdir -m 0755 -p /var/empty 
    5864 
    59         config_load $NAME 
    60         config_foreach start_service $NAME 
     65        config_load 'softflowd' 
     66        config_foreach start_instance 'softflowd' 
    6167} 
    6268 
    6369stop() { 
    64         config_load $NAME 
    65         config_foreach stop_service $NAME 
     70        config_load 'softflowd' 
     71        config_foreach stop_instance 'softflowd' 
     72        service_stop /usr/sbin/softflowd 
    6673} 
Note: See TracChangeset for help on using the changeset viewer.