/usr/share/fwbuilder-5.1.0.3599/configlets/linux24/shell_functions is in fwbuilder-common 5.1.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | ## -*- mode: shell-script; -*-
log() {
echo "$1"
which "$LOGGER" >/dev/null 2>&1 && $LOGGER -p info "$1"
}
getInterfaceVarName() {
echo $1 | sed 's/\./_/'
}
##
## getaddr6() reimplementation idea courtesy Juergen Kammer
## <j.kammer@eurodata.de> See ticket #651
##
## Can not use awk substr() function as originally suggested by
## Juergen because of the difference in behavior between GNU awk and
## mawk (a bug?). GNU awk substr() returns +1 character while mawk
## returns n characters. Tested with GNU awk v3.1.5 (CentOS 5.2) and
## mawk v1.3.3 (Ubuntu Jaunty)
##
## This sed command has been tested with GNU sed v4.1.5 and busybox v1.00
##
## getaddr has been reimplemented to return list of all ipv4 addresses
## of the interface. This is different from its behavior in fwbuilder
## v2 and v3 where it returned only the first address.
##
getaddr_internal() {
dev=$1
name=$2
af=$3
L=$($IP $af addr show dev $dev | sed -n '/inet/{s!.*inet6* !!;s!/.*!!p}' | sed 's/peer.*//')
test -z "$L" && {
eval "$name=''"
return
}
eval "${name}_list=\"$L\""
}
getnet_internal() {
dev=$1
name=$2
af=$3
L=$($IP route list proto kernel | grep $dev | grep -v default | sed 's! .*$!!')
test -z "$L" && {
eval "$name=''"
return
}
eval "${name}_list=\"$L\""
}
##
## This function reads all ipv4 addresses of interface (arg 1) and
## assignes the list to the variable which name is given as arg 2.
##
getaddr() {
getaddr_internal $1 $2 "-4"
}
##
## This function reads all ipv6 addresses of interface (arg 1) and
## assignes the list to the variable which name is given as arg 2.
##
getaddr6() {
getaddr_internal $1 $2 "-6"
}
##
## This function reads all ipv4 addresses of interface (arg 1) and
## assignes list of addresses of attached networks with their netmasks
## to the variable which name is given as arg 2.
##
getnet() {
getnet_internal $1 $2 "-4"
}
##
## This function reads all ipv6 addresses of interface (arg 1) and
## assignes list of addresses of attached networks with their netmasks
## to the variable which name is given as arg 2.
##
getnet6() {
getnet_internal $1 $2 "-6"
}
# function getinterfaces is used to process wildcard interfaces
getinterfaces() {
NAME=$1
$IP link show | grep ": $NAME" | while read L; do
OIFS=$IFS
IFS=" :"
set $L
IFS=$OIFS
echo $2
done
}
diff_intf() {
func=$1
list1=$2
list2=$3
cmd=$4
for intf in $list1
do
echo $list2 | grep -q $intf || {
# $vlan is absent in list 2
$func $intf $cmd
}
done
}
|