Browse Source

Merge pull request #5933 from alinnastac/rp-pppoe-improved-init-scripts

rp-pppoe: improve init scripts
lilik-openwrt-22.03
Hans Dedecker 7 years ago
committed by GitHub
parent
commit
caed4b5132
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 93 additions and 81 deletions
  1. +1
    -1
      net/rp-pppoe/Makefile
  2. +33
    -26
      net/rp-pppoe/files/pppoe-relay.init
  3. +59
    -54
      net/rp-pppoe/files/pppoe-server.init

+ 1
- 1
net/rp-pppoe/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=rp-pppoe
PKG_VERSION:=3.12
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_MAINTAINER:=Daniel Dickinson <lede@cshore.thecshore.com>
PKG_LICENSE:=LGPL-2.0+


+ 33
- 26
net/rp-pppoe/files/pppoe-relay.init View File

@ -2,28 +2,27 @@
# Copyright (C) 2006-2011 OpenWrt.org
START=50
STOP=50
USE_PROCD=1
pppoe_triggers() {
local cfg="$1"
local interface server_interfaces client_interfaces both_interfaces
local enabled interface server_interfaces client_interfaces both_interfaces
config_get_bool enabled "$cfg" enabled 1
[ "$enabled" -gt 0 ] || return 0
config_get server_interfaces "$cfg" server_interface
config_get client_interfaces "$cfg" client_interface
config_get both_interfaces "$cfg" both_interfaces
for interface in $server_interfaces; do
append interfaces "$interface" "|"
done
for interface in $client_interfaces; do
append interfaces "$interface" "|"
done
for interface in $both_interfaces; do
append interfaces "$interface" "|"
for interface in $server_interfaces $client_interfaces $both_interfaces; do
procd_add_reload_interface_trigger $interface
done
}
pppoe_relay_instance() {
local cfg="$1"
local interface server_interfaces client_interfaces both_interfaces maxsessions timeout OPTIONS
local enabled interface device server_interfaces client_interfaces both_interfaces maxsessions timeout OPTIONS
config_get_bool enabled "$cfg" enabled 1
[ "$enabled" -gt 0 ] || return 0
config_get server_interfaces "$cfg" server_interface
config_get client_interfaces "$cfg" client_interface
config_get both_interfaces "$cfg" both_interfaces
@ -34,39 +33,47 @@ pppoe_relay_instance() {
if [ "$use_non_uci_config" -gt 0 ]; then
. /etc/default/pppoe-relay
else
[ -z "${server_interfaces}${client_interfaces}${both_interfaces}" ] && return 1
local NEED_INTFS=SC
. /lib/functions/network.sh
for interface in $server_interfaces; do
append OPTIONS "-S $interface"
if network_get_physdev device $interface; then
append OPTIONS "-S $device"
NEED_INTFS=${NEED_INTFS/S/}
fi
done
for interface in $client_interfaces; do
append OPTIONS "-C $interface"
if network_get_physdev device $interface; then
append OPTIONS "-C $device"
NEED_INTFS=${NEED_INTFS/C/}
fi
done
for interface in $both_interfaces; do
append OPTIONS "-B $interface"
if network_get_physdev device $interface; then
append OPTIONS "-B $device"
NEED_INTFS=${NEED_INTFS/?/}
fi
done
[ -z "${NEED_INTFS}" ] || return 1 # need at least 2 interfaces, one for server(s) and one for client(s)
[ -n "$maxsessions" ] && append OPTIONS "-n $maxsessions"
[ -n "$timeout" ] && append OPTIONS "-i $timeout"
fi
procd_open_instance
procd_set_param command /usr/sbin/pppoe-relay -F
procd_append_param command $OPTIONS
procd_set_param command /usr/sbin/pppoe-relay -F $OPTIONS
procd_set_param respawn
procd_close_instance
}
start_service() {
local use_non_uci_config
local use_non_uci_config
config_load pppoe
config_foreach pppoe_relay_instance pppoe_relay
config_load pppoe
config_foreach pppoe_relay_instance pppoe_relay
}
reload_triggers() {
local interfaces
config_load pppoe
config_foreach pppoe_triggers pppoe_relay
service_triggers() {
procd_add_reload_trigger "pppoe"
procd_add_reload_trigger "pppoe"
procd_add_interface_trigger "$interfaces"
config_load pppoe
config_foreach pppoe_triggers pppoe_relay
}

+ 59
- 54
net/rp-pppoe/files/pppoe-server.init View File

@ -2,73 +2,78 @@
# Copyright (C) 2006-2011 OpenWrt.org
START=50
STOP=50
USE_PROCD=1
pppoe_triggers() {
local cfg="$1"
local interface
config_get interface "$cfg" interface
local cfg="$1"
local enabled interface
config_get_bool enabled "$cfg" enabled 1
[ "$enabled" -gt 0 ] || return 0
config_get interface "$cfg" interface
procd_add_reload_interface_trigger $interface
}
pppoe_instance() {
local cfg="$1"
local interface ac_name service_names service_name maxsessionsperpeer localip firstremoteip maxsessions optionsfiles randomsession unit offset timeout mss sync OPTIONS
config_get interface "$cfg" interface
config_get ac_name "$cfg" ac_name
config_get service_names "$cfg" service_name
config_get maxsessionsperpeer "$cfg" maxsessionsperpeer
config_get localip "$cfg" localip
config_get firstremoteip "$cfg" firstremoteip
config_get maxsessions "$cfg" maxsessions
config_get optionsfile "$cfg" optionsfile
config_get_bool randomsession "$cfg" randomsession 1
config_get_bool unit "$cfg" unit 0
config_get offset "$cfg" offset
config_get timeout "$cfg" timeout
config_get mss "$cfg" mss
config_get_bool sync "$cfg" sync 0
config_get use_non_uci_config "$cfg" use_non_uci_config 0
local cfg="$1"
local enabled interface device ac_name service_names service_name maxsessionsperpeer localip firstremoteip maxsessions optionsfiles randomsession unit offset timeout mss sync OPTIONS
config_get_bool enabled "$cfg" enabled 1
[ "$enabled" -gt 0 ] || return 0
config_get interface "$cfg" interface
config_get ac_name "$cfg" ac_name
config_get service_names "$cfg" service_name
config_get maxsessionsperpeer "$cfg" maxsessionsperpeer
config_get localip "$cfg" localip
config_get firstremoteip "$cfg" firstremoteip
config_get maxsessions "$cfg" maxsessions
config_get optionsfile "$cfg" optionsfile
config_get_bool randomsession "$cfg" randomsession 1
config_get_bool unit "$cfg" unit 0
config_get offset "$cfg" offset
config_get timeout "$cfg" timeout
config_get mss "$cfg" mss
config_get_bool sync "$cfg" sync 0
config_get_bool use_non_uci_config "$cfg" use_non_uci_config 0
if [ "$use_non_uci_config" -gt 0 ]; then
. /etc/default/pppoe-server
else
[ -z "$interface" ] && return 1
[ -n "$ac_name" ] && append OPTIONS "-C $ac_name"
for service_name in $service_names; do
append OPTIONS "-S $service_name"
done
append OPTIONS "-I $interface"
[ -n "$maxsessionsperpeer" ] && append OPTIONS "-x $maxsessionsperpeer"
[ -n "$localip" ] && append OPTIONS "-L $localip"
[ -n "$firstremoteip" ] && append OPTIONS "-R $firstremoteip"
[ -n "maxsessions" ] && append OPTIONS "-N $maxsessions"
[ -n "optionsfile" ] && append OPTIONS "-O $optionsfile"
[ "$randomsession" = "1" ] && append OPTIONS "-r"
[ "$unit" = "1" ] && append OPTIONS "-u"
[ -n "$offset" ] && append OPTIONS "-o $offset"
[ -n "$timeout" ] && append OPTIONS "-T $timeout"
[ -n "$mss" ] && append OPTIONS "-m $mss"
[ "$sync" = "1" ] && append OPTIONS "-s"
fi
if [ "$use_non_uci_config" -gt 0 ]; then
. /etc/default/pppoe-server
else
. /lib/functions/network.sh
network_get_physdev device $interface || return 1
[ -n "$ac_name" ] && append OPTIONS "-C $ac_name"
for service_name in $service_names; do
append OPTIONS "-S $service_name"
done
append OPTIONS "-I $device"
[ -n "$maxsessionsperpeer" ] && append OPTIONS "-x $maxsessionsperpeer"
[ -n "$localip" ] && append OPTIONS "-L $localip"
[ -n "$firstremoteip" ] && append OPTIONS "-R $firstremoteip"
[ -n "maxsessions" ] && append OPTIONS "-N $maxsessions"
[ -n "optionsfile" ] && append OPTIONS "-O $optionsfile"
[ "$randomsession" = "1" ] && append OPTIONS "-r"
[ "$unit" = "1" ] && append OPTIONS "-u"
[ -n "$offset" ] && append OPTIONS "-o $offset"
[ -n "$timeout" ] && append OPTIONS "-T $timeout"
[ -n "$mss" ] && append OPTIONS "-m $mss"
[ "$sync" = "1" ] && append OPTIONS "-s"
fi
procd_open_instance
procd_set_param command /usr/sbin/pppoe-server -F
procd_append_param command -k $OPTIONS
procd_set_param file /etc/ppp/options
procd_append_param file /etc/ppp/pppoe-server-options
procd_close_instance
procd_open_instance
procd_set_param command /usr/sbin/pppoe-server -F -k $OPTIONS
procd_set_param respawn
procd_set_param file /etc/ppp/options
procd_append_param file /etc/ppp/pppoe-server-options
procd_close_instance
}
start_service() {
config_load pppoe
config_foreach pppoe_instance pppoe_server
config_load pppoe
config_foreach pppoe_instance pppoe_server
}
service_triggers() {
local interface
config_load pppoe
config_foreach pppoe_triggers pppoe_server
procd_add_reload_trigger "pppoe"
procd_add_reload_trigger "pppoe"
procd_add_interface_trigger "$interface"
config_load pppoe
config_foreach pppoe_triggers pppoe_server
}

Loading…
Cancel
Save