Project

General

Profile

Download (1.89 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
#
3
# ppp-linkdown
4
#
5
# part of pfSense (https://www.pfsense.org)
6
# Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7
# All rights reserved.
8
#
9
# Licensed under the Apache License, Version 2.0 (the "License");
10
# you may not use this file except in compliance with the License.
11
# You may obtain a copy of the License at
12
#
13
# http://www.apache.org/licenses/LICENSE-2.0
14
#
15
# Unless required by applicable law or agreed to in writing, software
16
# distributed under the License is distributed on an "AS IS" BASIS,
17
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
# See the License for the specific language governing permissions and
19
# limitations under the License.
20

    
21
IF="${1}"
22
PROTOCOL="${2}"
23
LOCAL_IP="${3}"
24

    
25
if [ -f /tmp/${IF}up ] && [ -f /conf/${IF}.log ]; then
26
	seconds=$((`date -j +%s` - `/usr/bin/stat -f %m /tmp/${IF}up`))
27
	/usr/local/sbin/ppp-log-uptime.sh $seconds ${IF} &
28
fi
29

    
30
if echo "${IF}" | /usr/bin/egrep -qv "ppp[0-9]+"; then
31
	/etc/rc.kill_states ${IF} ${LOCAL_IP}
32
fi
33

    
34
if [ "${PROTOCOL}" == "inet" && -s "/tmp/${IF}_defaultgw" ]; then
35
	GW=`head -n 1 /tmp/${IF}_defaultgw`
36
	DGW=`/sbin/route -n get -inet default | /usr/bin/awk '/gateway:/ {print $2}'`
37
	# Only remove the default gateway if it matches the gateway for this interface. See redmine #1837
38
	if [ "${GW}" = "${DGW}" ]; then
39
		/sbin/route -q delete default ${GW}
40
	fi
41
fi
42

    
43
if [ "${PROTOCOL}" == "inet6" ]; then
44
	/usr/local/sbin/ppp-ipv6 ${IF} down
45
fi
46
# delete the node just in case mpd cannot do that
47
/usr/sbin/ngctl shutdown ${IF}:
48
if [ -f "/var/etc/nameserver_${IF}" ]; then
49
	# Remove old entries
50
	for nameserver in `cat /var/etc/nameserver_${IF}`; do
51
		/sbin/route -q delete ${nameserver} >/dev/null 2>&1
52
	done
53
	/bin/rm -f /var/etc/nameserver_${IF}
54
fi
55
# Do not remove gateway used during filter reload.
56
/bin/rm -f /tmp/${IF}_router
57
/bin/rm -f /tmp/${IF}up
58
/bin/rm -f /tmp/${IF}_ip
59
/usr/local/sbin/pfSctl -c 'service reload dns'
(13-13/23)