Move detection code to separate scripts for easy customization
parent
d8b630e09d
commit
70a2559ec3
|
@ -106,12 +106,16 @@ fi
|
||||||
|
|
||||||
|
|
||||||
if [[ "$EXTIF" == "auto" ]]; then
|
if [[ "$EXTIF" == "auto" ]]; then
|
||||||
|
if [ ! "$EXTIF_FIND" ]; then
|
||||||
|
|
||||||
EXTIF=$EXTIF_FIND
|
EXTIF=$EXTIF_FIND
|
||||||
display_c YELLOW "Found default interface at: ${BLUE}${EXTIF}${DEFAULT_COLOR}"
|
display_c YELLOW "Found default interface at: ${BLUE}${EXTIF}${DEFAULT_COLOR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$EXTIP" == "auto" ]]; then
|
if [[ "$EXTIP" == "auto" ]]; then
|
||||||
EXTIP=$EXTIP_FIND
|
if [ ! "$EXTIP_FIND" ]; then
|
||||||
|
EXTIP=$(expr "`ifconfig ${EXTIF}`" : '.*inet addr:\([^ ]*\).*')
|
||||||
|
fi
|
||||||
display_c YELLOW "Found default interface IP at: ${BLUE}${EXTIP}${DEFAULT_COLOR}"
|
display_c YELLOW "Found default interface IP at: ${BLUE}${EXTIP}${DEFAULT_COLOR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
ip route | awk '/^default/{print $3}'
|
||||||
|
#netstat -rn | awk '/^0.0.0.0/{print $8}'
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Thanks to the people at:
|
||||||
|
# http://www.linuxquestions.org/questions/programming-9/using-grep-and-awk-to-get-ip-address-627626/
|
||||||
|
|
||||||
|
echo $(expr "`ifconfig $1`" : '.*inet addr:\([^ ]*\).*')
|
||||||
|
|
||||||
|
#ifconfig ${EXTIF}| awk -F ' *|:' '/inet addr/{print $4}'
|
|
@ -171,4 +171,4 @@ function write_out_rules {
|
||||||
}
|
}
|
||||||
function write_out_rules_v6 {
|
function write_out_rules_v6 {
|
||||||
echo "$*" >> "$RULE_CACHE_V6"
|
echo "$*" >> "$RULE_CACHE_V6"
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,5 +69,5 @@ RULE_CACHE_V6=$BASEDIR/cache/ipt6-rules
|
||||||
|
|
||||||
EXTIP="auto"
|
EXTIP="auto"
|
||||||
EXTIF="auto"
|
EXTIF="auto"
|
||||||
EXTIF_FIND=`ip route | awk '/^default/{print $3}'`
|
EXTIF_FIND="$BASEDIR/bin/get_default_if"
|
||||||
EXTIP_FIND=$(expr "`ifconfig ${EXTIF}`" : '.*inet addr:\([^ ]*\).*')
|
EXTIP_FIND="$BASEDIR/bin/get_default_ip"
|
|
@ -57,22 +57,18 @@ EXTIF="auto"
|
||||||
# the primary external IP using the information from EXTIF
|
# the primary external IP using the information from EXTIF
|
||||||
EXTIP="auto"
|
EXTIP="auto"
|
||||||
|
|
||||||
|
# Program/script for finding the default external interface
|
||||||
|
# Only used if EXTIF is set to auto
|
||||||
|
#
|
||||||
|
# If you need to write your own script to find the info, change below
|
||||||
|
#EXTIF_FIND="$BASEDIR/bin/get_default_if"
|
||||||
|
|
||||||
# Pattern for finding the default external interface IP address
|
# Pattern for finding the default external interface IP address
|
||||||
# Only used if EXTIP is set to auto
|
# Only used if EXTIP is set to auto
|
||||||
#
|
#
|
||||||
# Thanks to the people at:
|
# If you need to write your own script to find the info, change below
|
||||||
# http://www.linuxquestions.org/questions/programming-9/using-grep-and-awk-to-get-ip-address-627626/
|
# note that the script passes the interface from $EXTIF as first option
|
||||||
#
|
#EXTIP_FIND="$BASEDIR/bin/get_default_ip"
|
||||||
# Uncomment one of these if the default doesn't work
|
|
||||||
#EXTIP_FIND=$(expr "`ifconfig ${EXTIF}`" : '.*inet addr:\([^ ]*\).*')
|
|
||||||
#EXTIP_FIND=`ifconfig ${EXTIF}| awk -F ' *|:' '/inet addr/{print $4}'`
|
|
||||||
|
|
||||||
# Pattern for finding the default external interface
|
|
||||||
# Only used if EXTIF is set to auto
|
|
||||||
#
|
|
||||||
# Uncomment one of these if the default doesn't work
|
|
||||||
#EXTIF_FIND=`ip route | awk '/^default/{print $3}'`
|
|
||||||
#EXTIF_FIND=`netstat -rn | awk '/^0.0.0.0/{print $8}'`
|
|
||||||
|
|
||||||
# Internal Interface
|
# Internal Interface
|
||||||
#INTINF=ppp+
|
#INTINF=ppp+
|
||||||
|
|
Loading…
Reference in New Issue