Revision 2c27096c
Added by Renato Botelho over 12 years ago
usr/local/sbin/ppp-linkdown | ||
---|---|---|
1 | 1 |
#!/bin/sh |
2 |
if [ -f /tmp/$1up ] && [ -f /conf/$1.log ]; then |
|
3 |
seconds=$((`date -j +%s` - `/usr/bin/stat -f %m /tmp/$1up`)) |
|
4 |
/usr/local/sbin/ppp-log-uptime.sh $seconds $1 & |
|
2 |
|
|
3 |
IF="${1}" |
|
4 |
LOCAL_IP="${3}" |
|
5 |
|
|
6 |
if [ -f /tmp/${IF}up ] && [ -f /conf/${IF}.log ]; then |
|
7 |
seconds=$((`date -j +%s` - `/usr/bin/stat -f %m /tmp/${IF}up`)) |
|
8 |
/usr/local/sbin/ppp-log-uptime.sh $seconds ${IF} & |
|
5 | 9 |
fi |
6 |
if [ "$3" != "" ]; then |
|
7 |
if echo "$3" | grep -q '/'; then |
|
8 |
LOCAL_IP="${3}" |
|
9 |
else |
|
10 |
LOCAL_IP="${3}/32" |
|
10 |
if [ -n "${LOCAL_IP}" ]; then |
|
11 |
if ! echo "${LOCAL_IP}" | grep -q "/"; then |
|
12 |
LOCAL_IP="${LOCAL_IP}/32" |
|
11 | 13 |
fi |
12 |
|
|
13 |
echo "Removing states from ${LOCAL_IP}" | logger -t ppp-linkdown |
|
14 |
echo "Removing states from ${LOCAL_IP}" | /usr/bin/logger -t ppp-linkdown |
|
14 | 15 |
/sbin/pfctl -k 0.0.0.0/0 -k ${LOCAL_IP} |
15 | 16 |
/sbin/pfctl -k ${LOCAL_IP} |
16 |
pfctl -K ${LOCAL_IP} |
|
17 |
pfctl -i $1 -Fs
|
|
17 |
/sbin/pfctl -K ${LOCAL_IP}
|
|
18 |
/sbin/pfctl -i ${IF} -Fs
|
|
18 | 19 |
fi |
19 | 20 |
|
20 |
/sbin/pfctl -i $1 -Fs
|
|
21 |
if [ -f "/tmp/${1}_defaultgw" ]; then
|
|
22 |
route delete default `head -n 1 /tmp/${1}_defaultgw`;
|
|
21 |
/sbin/pfctl -i ${IF} -Fs
|
|
22 |
if [ -f "/tmp/${IF}_defaultgw" ]; then
|
|
23 |
/sbin/route delete default `/usr/bin/head -n 1 /tmp/${IF}_defaultgw`;
|
|
23 | 24 |
fi |
24 | 25 |
# delete the node just in case mpd cannot do that |
25 |
/usr/sbin/ngctl shutdown $1:
|
|
26 |
if [ -f "/var/etc/nameserver_$1" ]; then
|
|
26 |
/usr/sbin/ngctl shutdown ${IF}:
|
|
27 |
if [ -f "/var/etc/nameserver_${IF}" ]; then
|
|
27 | 28 |
# Remove old entries |
28 |
for nameserver in `cat /var/etc/nameserver_$1`; do
|
|
29 |
/sbin/route delete $nameserver >/dev/null 2>&1
|
|
29 |
for nameserver in `cat /var/etc/nameserver_${IF}`; do
|
|
30 |
/sbin/route delete ${nameserver} >/dev/null 2>&1
|
|
30 | 31 |
done |
31 |
/bin/rm -f /var/etc/nameserver_$1
|
|
32 |
/bin/rm -f /var/etc/nameserver_${IF}
|
|
32 | 33 |
fi |
33 | 34 |
# Do not remove gateway used during filter reload. |
34 |
/bin/rm -f /tmp/$1_router
|
|
35 |
/bin/rm -f /tmp/$1up
|
|
36 |
/bin/rm -f /tmp/$1_ip
|
|
35 |
/bin/rm -f /tmp/${IF}_router
|
|
36 |
/bin/rm -f /tmp/${IF}up
|
|
37 |
/bin/rm -f /tmp/${IF}_ip
|
|
37 | 38 |
/usr/local/sbin/pfSctl -c 'service reload dns' |
Also available in: Unified diff
Improve ppp-linkdown:
- Improve readability giving name to parameter variables
- Add path for all command calls