mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
twamp: fixed shellcheck errors
This commit is contained in:
parent
57733d7f69
commit
1ab88ddc70
4 changed files with 17 additions and 20 deletions
|
|
@ -6,7 +6,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=twamp
|
||||
PKG_VERSION:=1.2.4
|
||||
PKG_VERSION:=1.2.5
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
|
|
|
|||
|
|
@ -10,29 +10,27 @@ if [ ! -f "/etc/config/twamp" ]; then
|
|||
exit 0;
|
||||
fi
|
||||
|
||||
function configure_firewall()
|
||||
{
|
||||
configure_firewall() {
|
||||
local enable port interface
|
||||
|
||||
config_get enable ${1} enable "1"
|
||||
config_get port ${1} port
|
||||
config_get interface ${1} interface
|
||||
if [ "$enable" -eq 0 -o -z "${port}" -o -z "${interface}" ]; then
|
||||
config_get enable "${1}" enable "1"
|
||||
config_get port "${1}" port
|
||||
config_get interface "${1}" interface
|
||||
if [ "$enable" -eq 0 ] || [ -z "${port}" ] || [ -z "${interface}" ]; then
|
||||
return 0;
|
||||
fi
|
||||
|
||||
iptables -w 1 -nL zone_${interface}_input 2>/dev/null 1>&2
|
||||
iptables -w 1 -nL zone_"${interface}"_input 2>/dev/null 1>&2
|
||||
if [ "$?" -eq 0 ]; then
|
||||
iptables -w 1 -I zone_${interface}_input -p udp --dport "${port}" -j ACCEPT -m comment --comment "TWAMP reflector port"
|
||||
iptables -w 1 -I zone_"${interface}"_input -p udp --dport "${port}" -j ACCEPT -m comment --comment "TWAMP reflector port"
|
||||
fi
|
||||
}
|
||||
|
||||
function delete_rule()
|
||||
{
|
||||
while iptables -w 1 -nL zone_${1}_input --line-numbers 2>/dev/null | grep "TWAMP reflector port"; do
|
||||
rule_num="$(iptables -w 1 -nL zone_${1}_input --line-numbers | grep "TWAMP reflector port" | head -1|awk '{print $1}')"
|
||||
delete_rule() {
|
||||
while iptables -w 1 -nL zone_"${1}"_input --line-numbers 2>/dev/null | grep "TWAMP reflector port"; do
|
||||
rule_num="$(iptables -w 1 -nL zone_"${1}"_input --line-numbers | grep "TWAMP reflector port" | head -1|awk '{print $1}')"
|
||||
if [ -n "${rule_num}" ]; then
|
||||
iptables -w 1 -D zone_${1}_input ${rule_num};
|
||||
iptables -w 1 -D zone_"${1}"_input "${rule_num}";
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ USE_PROCD=1
|
|||
PROG="/usr/sbin/twampd"
|
||||
|
||||
start_service() {
|
||||
local enable=`uci -q get twamp.twamp.enable`
|
||||
local enable=$(uci -q get twamp.twamp.enable)
|
||||
if [ "$enable" = "1" ]; then
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@
|
|||
|
||||
. /lib/functions.sh
|
||||
|
||||
function rename_section()
|
||||
{
|
||||
rename_section() {
|
||||
local enable inst
|
||||
|
||||
config_get interface ${1} interface ""
|
||||
config_get interface "${1}" interface ""
|
||||
if [ -z "${interface}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
inst="$(echo ${1}|cut -d '_' -f 2)"
|
||||
uci_rename twamp ${1} "${interface}_${inst}"
|
||||
inst="$(echo "${1}"|cut -d '_' -f 2)"
|
||||
uci_rename twamp "${1}" "${interface}_${inst}"
|
||||
}
|
||||
|
||||
config_load twamp
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue