diff options
author | Renato Botelho <garga@FreeBSD.org> | 2013-03-19 10:07:33 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2013-03-19 15:36:53 -0300 |
commit | 2c27096c9c2f86687de78080df317a275cc7ee1e (patch) | |
tree | 4d69458ec20f2eeb7576e15330481ee01db4a3aa /usr/local/sbin/ppp-linkdown | |
parent | 6d5460e650aae29111de0d16ca82d5ffc2ad59af (diff) | |
download | pfsense-2c27096c9c2f86687de78080df317a275cc7ee1e.zip pfsense-2c27096c9c2f86687de78080df317a275cc7ee1e.tar.gz |
Improve ppp-linkdown:
- Improve readability giving name to parameter variables
- Add path for all command calls
Diffstat (limited to 'usr/local/sbin/ppp-linkdown')
-rwxr-xr-x | usr/local/sbin/ppp-linkdown | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/usr/local/sbin/ppp-linkdown b/usr/local/sbin/ppp-linkdown index 17998da..9383cdd 100755 --- a/usr/local/sbin/ppp-linkdown +++ b/usr/local/sbin/ppp-linkdown @@ -1,37 +1,38 @@ #!/bin/sh -if [ -f /tmp/$1up ] && [ -f /conf/$1.log ]; then - seconds=$((`date -j +%s` - `/usr/bin/stat -f %m /tmp/$1up`)) - /usr/local/sbin/ppp-log-uptime.sh $seconds $1 & + +IF="${1}" +LOCAL_IP="${3}" + +if [ -f /tmp/${IF}up ] && [ -f /conf/${IF}.log ]; then + seconds=$((`date -j +%s` - `/usr/bin/stat -f %m /tmp/${IF}up`)) + /usr/local/sbin/ppp-log-uptime.sh $seconds ${IF} & fi -if [ "$3" != "" ]; then - if echo "$3" | grep -q '/'; then - LOCAL_IP="${3}" - else - LOCAL_IP="${3}/32" +if [ -n "${LOCAL_IP}" ]; then + if ! echo "${LOCAL_IP}" | grep -q "/"; then + LOCAL_IP="${LOCAL_IP}/32" fi - - echo "Removing states from ${LOCAL_IP}" | logger -t ppp-linkdown + echo "Removing states from ${LOCAL_IP}" | /usr/bin/logger -t ppp-linkdown /sbin/pfctl -k 0.0.0.0/0 -k ${LOCAL_IP} /sbin/pfctl -k ${LOCAL_IP} - pfctl -K ${LOCAL_IP} - pfctl -i $1 -Fs + /sbin/pfctl -K ${LOCAL_IP} + /sbin/pfctl -i ${IF} -Fs fi -/sbin/pfctl -i $1 -Fs -if [ -f "/tmp/${1}_defaultgw" ]; then - route delete default `head -n 1 /tmp/${1}_defaultgw`; +/sbin/pfctl -i ${IF} -Fs +if [ -f "/tmp/${IF}_defaultgw" ]; then + /sbin/route delete default `/usr/bin/head -n 1 /tmp/${IF}_defaultgw`; fi # delete the node just in case mpd cannot do that -/usr/sbin/ngctl shutdown $1: -if [ -f "/var/etc/nameserver_$1" ]; then +/usr/sbin/ngctl shutdown ${IF}: +if [ -f "/var/etc/nameserver_${IF}" ]; then # Remove old entries - for nameserver in `cat /var/etc/nameserver_$1`; do - /sbin/route delete $nameserver >/dev/null 2>&1 + for nameserver in `cat /var/etc/nameserver_${IF}`; do + /sbin/route delete ${nameserver} >/dev/null 2>&1 done - /bin/rm -f /var/etc/nameserver_$1 + /bin/rm -f /var/etc/nameserver_${IF} fi # Do not remove gateway used during filter reload. -/bin/rm -f /tmp/$1_router -/bin/rm -f /tmp/$1up -/bin/rm -f /tmp/$1_ip +/bin/rm -f /tmp/${IF}_router +/bin/rm -f /tmp/${IF}up +/bin/rm -f /tmp/${IF}_ip /usr/local/sbin/pfSctl -c 'service reload dns' |