Don't use 'ifconfig' anymore. Get rid of special ppp handling.
This commit is contained in:
parent
044cfaac7c
commit
d9c671252c
101
test_email.sh
101
test_email.sh
@ -7,44 +7,19 @@ datum=`/bin/date +"%d.%m.%Y"`
|
|||||||
email_to=$1
|
email_to=$1
|
||||||
email_to=${email_to:="root"}
|
email_to=${email_to:="root"}
|
||||||
|
|
||||||
email_from="`whoami`@`hostname --long`"
|
email_from="$(whoami)@$(hostname --long)"
|
||||||
|
|
||||||
file=/tmp/mail_ip-up$$
|
file=/tmp/mail_ip-up$$
|
||||||
|
|
||||||
if [ -f /etc/ddclient.conf ]; then
|
INET_INTERFACE="$(netstat -rn | grep -e"^0.0.0" | awk '{print$8}')"
|
||||||
|
if [[ -n "$INET_INTERFACE" ]] ; then
|
||||||
# Check, if this is the interface used for DynDNS (there could be other pppds
|
EXTERN_IPv4="$(ip addr show $INET_INTERFACE | grep -E "\s+inet\s+" | awk '{print$2}')"
|
||||||
eval `sed -n 's/\(if=[^ ,]*\)/\1/p' /etc/ddclient.conf`
|
EXTERN_IPv6="$(ip addr show $INET_INTERFACE | grep global | grep -E "\s+inet6\s+" | awk '{print$2}')"
|
||||||
|
|
||||||
## - check if interface used by dydns is present
|
|
||||||
## -
|
|
||||||
for _IFACE in `ifconfig | grep -e"^ppp" | cut -d" " -f1 `; do
|
|
||||||
if [ "$_IFACE" = "$if" ];then
|
|
||||||
PPP_IFACE=$_IFACE
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$PPP_IFACE" ] ; then
|
|
||||||
PPP_REMOTE=`ifconfig $PPP_IFACE 2>/dev/null | grep -e "P-[tz]-P" | cut -d":" -f3 | cut -d " " -f1`
|
|
||||||
PPP_LOCAL=`ifconfig $PPP_IFACE 2>/dev/null | grep -e "P-[tz]-P" | cut -d":" -f2 | cut -d " " -f1`
|
|
||||||
else
|
|
||||||
INET_INTERFACE="$(netstat -rn | grep -e"^0.0.0" | awk '{print$8}')"
|
|
||||||
EXTERN_IPv4="$(ifconfig | grep -A 1 $INET_INTERFACE | grep "inet Adresse" | cut -d":" -f2 | cut -d " " -f1)"
|
|
||||||
EXTERN_IPv6="$(ifconfig | grep -A 3 $INET_INTERFACE | grep -i global | grep -E "^\s+inet6-" | awk '{print$2}')"
|
|
||||||
if [[ -z "$EXTERN_IPv4" ]] ; then
|
|
||||||
EXTERN_IPv4="$(ip addr show $INET_INTERFACE | grep -E "\s+inet\s+" | awk '{print$2}')"
|
|
||||||
fi
|
|
||||||
if [[ -z "$EXTERN_IPv6" ]] ; then
|
|
||||||
EXTERN_IPv6="$(ip addr show $INET_INTERFACE | grep global | grep -E "\s+inet6\s+" | awk '{print$2}')"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
DNS_SERVER=`cat /etc/resolv.conf | grep -v -e"^#" | grep nameserver | cut -d " " -f2`
|
DNS_SERVER="$(cat /etc/resolv.conf | grep -v -e"^#" | grep nameserver | cut -d " " -f2)"
|
||||||
DEFAULT_GW=`netstat -rn | grep -e"^0.0.0" | awk '{print$2}'`;
|
DEFAULT_GW="$(netstat -rn | grep -e"^0.0.0" | awk '{print$2}')"
|
||||||
|
|
||||||
echo "" > $file
|
echo "" > $file
|
||||||
echo " *******************************************************" >> $file
|
echo " *******************************************************" >> $file
|
||||||
@ -54,40 +29,28 @@ echo -e "\tHost.........................: `hostname --long`" >> $file
|
|||||||
echo "" >> $file
|
echo "" >> $file
|
||||||
echo -e "\tSender.......................: $email_from" >> $file
|
echo -e "\tSender.......................: $email_from" >> $file
|
||||||
echo "" >> $file
|
echo "" >> $file
|
||||||
if [ "$PPP_IFACE" ] ; then
|
if [[ -n "$INET_INTERFACE" ]] ; then
|
||||||
echo -e "\tInterface name...............: $PPP_IFACE" >> $file
|
echo -e "\tInterface extern.............: $INET_INTERFACE" >> $file
|
||||||
echo -e "\tLocal IP number..............: $PPP_LOCAL" >> $file
|
echo "" >> $file
|
||||||
echo -e "\tPeer IP number..............: $PPP_REMOTE" >> $file
|
declare -i i=1
|
||||||
if [ "$USEPEERDNS" ] && [ "$DNS1" ] ; then
|
for ip in $EXTERN_IPv4 ; do
|
||||||
echo -e "\tNameserver 1.................: $DNS1" >> $file
|
if [ $i -eq 1 ]; then
|
||||||
if [ "$DNS2" ] ; then
|
echo -e "\tLocal IPv4 address...........: $ip" >> $file
|
||||||
echo -e "\tNameserver 2.................: $DNS2" >> $file
|
else
|
||||||
|
echo -e "\t $ip" >> $file
|
||||||
fi
|
fi
|
||||||
fi
|
let i++
|
||||||
else
|
done
|
||||||
if [ "$INET_INTERFACE" ];then
|
i=1
|
||||||
echo -e "\tInterface extern.............: $INET_INTERFACE" >> $file
|
for ip in $EXTERN_IPv6 ; do
|
||||||
echo "" >> $file
|
if [ $i -eq 1 ]; then
|
||||||
declare -i i=1
|
echo "" >> $file
|
||||||
for ip in $EXTERN_IPv4 ; do
|
echo -e "\tLocal IPv6 address...........: $ip" >> $file
|
||||||
if [ $i -eq 1 ]; then
|
else
|
||||||
echo -e "\tLocal IPv4 address...........: $ip" >> $file
|
echo -e "\t $ip" >> $file
|
||||||
else
|
fi
|
||||||
echo -e "\t $ip" >> $file
|
let i++
|
||||||
fi
|
done
|
||||||
let i++
|
|
||||||
done
|
|
||||||
i=1
|
|
||||||
for ip in $EXTERN_IPv6 ; do
|
|
||||||
if [ $i -eq 1 ]; then
|
|
||||||
echo "" >> $file
|
|
||||||
echo -e "\tLocal IPv6 address...........: $ip" >> $file
|
|
||||||
else
|
|
||||||
echo -e "\t $ip" >> $file
|
|
||||||
fi
|
|
||||||
let i++
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
echo "" >> $file
|
echo "" >> $file
|
||||||
if [ "$DEFAULT_GW" ] ; then
|
if [ "$DEFAULT_GW" ] ; then
|
||||||
@ -100,15 +63,15 @@ for dns in $DNS_SERVER ; do
|
|||||||
let i++
|
let i++
|
||||||
done
|
done
|
||||||
echo "" >> $file
|
echo "" >> $file
|
||||||
echo -e "\tDate.........................: `date +\"%d.%m.%Y\"`" >> $file
|
echo -e "\tDate.........................: $(date +"%d.%m.%Y")" >> $file
|
||||||
echo -e "\tTime.........................: `date +\"%H:%M:%S\"`" >> $file
|
echo -e "\tTime.........................: $(date +"%H:%M:%S")" >> $file
|
||||||
echo "" >> $file
|
echo "" >> $file
|
||||||
echo " *** ***" >> $file
|
echo " *** ***" >> $file
|
||||||
echo " *******************************************************" >> $file
|
echo " *******************************************************" >> $file
|
||||||
|
|
||||||
|
|
||||||
echo -e "From:${email_from}\nTo:${email_to}\nSubject:Test on `hostname --long` at $datum\n\n`/bin/cat $file`" | /usr/sbin/sendmail -F '`whoami`' -f $email_from $email_to
|
echo -e "From:${email_from}\nTo:${email_to}\nSubject:Test on $(hostname --long) at $datum\n\n$(/bin/cat $file)" | /usr/sbin/sendmail -F "$(whoami)" -f $email_from $email_to
|
||||||
|
|
||||||
|
|
||||||
rm -f $file
|
rm -f $file
|
||||||
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user