interfaces: deprecate *up(v6) files, PPP is only user

Create a more distinguished file _uptime which could be used later
for other things.  Adjust scripting and remove unneeded cruft.
This commit is contained in:
Franco Fichtner 2021-10-05 10:09:12 +02:00
parent 662e241eed
commit f129c4682b
8 changed files with 15 additions and 27 deletions

1
plist
View File

@ -739,7 +739,6 @@
/usr/local/opnsense/scripts/interfaces/mpd.script
/usr/local/opnsense/scripts/interfaces/ppp-linkdown.sh
/usr/local/opnsense/scripts/interfaces/ppp-linkup.sh
/usr/local/opnsense/scripts/interfaces/ppp-log-uptime.sh
/usr/local/opnsense/scripts/interfaces/ppp-uptime.sh
/usr/local/opnsense/scripts/interfaces/traffic_stats.php
/usr/local/opnsense/scripts/interfaces/traffic_top.py

View File

@ -1122,8 +1122,6 @@ function interface_bring_down($interface = "wan", $ifacecfg = false)
@unlink("/var/etc/nameserver_v6{$realifv6}");
@unlink("/var/etc/searchdomain_{$realif}");
@unlink("/var/etc/searchdomain_v6{$realifv6}");
@unlink("/tmp/{$realif}up");
@unlink("/tmp/{$realifv6}upv6");
@unlink("/tmp/{$realif}_router");
@unlink("/tmp/{$realifv6}_routerv6");
@unlink("/tmp/{$realifv6}_pdinfo");

View File

@ -4,8 +4,6 @@
/bin/rm -f /tmp/$1_router
/bin/rm -f /tmp/$1_routerv6
/bin/rm -f /tmp/$1up
/bin/rm -f /tmp/$1upv6
/bin/rm -f /var/etc/nameserver_v6$1
/bin/rm -f /var/etc/nameserver_$1
/bin/rm -f /var/etc/searchdomain_$1

View File

@ -1,8 +1,5 @@
#!/bin/sh
# let the configuration system know that the ip has changed.
# /usr/local/opnsense/service/configd_ctl.py interface newip $interface
if [ -n "${route_vpn_gateway}" ]; then
/bin/echo ${route_vpn_gateway} > /tmp/$1_router
elif [ -n "${ifconfig_remote}" ]; then
@ -21,9 +18,6 @@ elif [ -n "${ifconfig_ipv6_local}" ]; then
/bin/echo ${ifconfig_ipv6_local} > /tmp/${1}_routerv6
fi
/usr/bin/touch /tmp/$1up
/usr/bin/touch /tmp/$1upv6
/usr/local/opnsense/service/configd_ctl.py interface newip $1
exit 0

View File

@ -12,11 +12,6 @@ DEFAULTGW=$(route -n get -${AF} default | grep gateway: | awk '{print $2}')
ngctl shutdown ${IF}:
if [ "${AF}" = "inet" ]; then
if [ -f /tmp/${IF}up -a -f /conf/${IF}.log ]; then
seconds=$((`date -j +%s` - `/usr/bin/stat -f %m /tmp/${IF}up`))
/usr/local/opnsense/scripts/interfaces/ppp-log-uptime.sh $seconds ${IF} &
fi
if [ -s "/tmp/${IF}_defaultgw" ]; then
GW=$(head -n 1 /tmp/${IF}_defaultgw)
fi
@ -34,7 +29,7 @@ if [ "${AF}" = "inet" ]; then
fi
# Do not remove gateway used during filter reload.
rm -f /tmp/${IF}_router /tmp/${IF}up /tmp/${IF}_ip
rm -f /tmp/${IF}_router /tmp/${IF}_ip
elif [ "${AF}" = "inet6" ]; then
if [ -s "/tmp/${IF}_defaultgwv6" ]; then
GW=$(head -n 1 /tmp/${IF}_defaultgwv6)
@ -53,7 +48,7 @@ elif [ "${AF}" = "inet6" ]; then
fi
# Do not remove gateway used during filter reload.
rm -f /tmp/${IF}_routerv6 /tmp/${IF}upv6 /tmp/${IF}_ipv6
rm -f /tmp/${IF}_routerv6 /tmp/${IF}_ipv6
# remove previous SLAAC addresses as the ISP may
# not respond to these in the upcoming session
@ -64,4 +59,11 @@ fi
daemon -f /usr/local/opnsense/service/configd_ctl.py dns reload
UPTIME=$(opnsense/scripts/interfaces/ppp-uptime.sh ${IF})
if [ -n "${UPTIME}" -a -f "/conf/${IF}.log" ]; then
echo $(date -j +%Y.%m.%d-%H:%M:%S) ${UPTIME} >> /conf/${IF}.log
fi
rm -f /tmp/${IF}_uptime
exit 0

View File

@ -10,10 +10,8 @@ if [ "${2}" = "inet" ]; then
pfctl -i ${1} -k ${OLD_ROUTER}/32 -k 0.0.0.0/0
fi
# let the configuration system know that the ipv4 has changed.
echo ${4} > /tmp/${1}_router
echo ${3} > /tmp/${1}_ip
touch /tmp/${1}up
if grep -q dnsallowoverride /conf/config.xml; then
# write nameservers to file
@ -34,10 +32,8 @@ if [ "${2}" = "inet" ]; then
daemon -f /usr/local/opnsense/service/configd_ctl.py interface newip ${1}
elif [ "${2}" = "inet6" ]; then
# let the configuration system know that the ipv6 has changed.
echo ${4} |cut -d% -f1 > /tmp/${1}_routerv6
echo ${3} |cut -d% -f1 > /tmp/${1}_ipv6
touch /tmp/${1}upv6
if grep -q dnsallowoverride /conf/config.xml; then
# write nameservers to file
@ -59,4 +55,6 @@ elif [ "${2}" = "inet6" ]; then
daemon -f /usr/local/opnsense/service/configd_ctl.py interface newipv6 ${1}
fi
touch /tmp/${1}_uptime
exit 0

View File

@ -1,3 +0,0 @@
#!/bin/sh
#write the uptime in seconds to the persistent log in /conf/
/bin/echo `date -j +%Y.%m.%d-%H:%M:%S` $1 >> /conf/$2.log

View File

@ -1,3 +1,5 @@
#!/bin/sh
#get ppp uptime from age of /tmp/{interface}up file
[ -f /tmp/$1up ] && /bin/echo $((`date -j +%s` - `/usr/bin/stat -f %m /tmp/$1up`))
if [ -f /tmp/${1}_uptime ]; then
echo $((`date -j +%s` - `/usr/bin/stat -f %m /tmp/${1}_uptime`))
fi