Annotation of /trunk/ppp/ip-up
Parent Directory | Revision Log
Revision 303 -
(hide annotations)
(download)
Sat Aug 18 18:50:53 2007 UTC (17 years, 2 months ago) by niro
File size: 1480 byte(s)
Sat Aug 18 18:50:53 2007 UTC (17 years, 2 months ago) by niro
File size: 1480 byte(s)
-support files for pppd
1 | niro | 303 | #!/bin/sh |
2 | # $Header: /root/magellan-cvs/src/ppp/ip-up,v 1.1 2007-08-18 18:50:53 niro Exp $ | ||
3 | # | ||
4 | # This script is run by pppd when there's a successful ppp connection. | ||
5 | # | ||
6 | |||
7 | # the following parameters are available: | ||
8 | # $1 = interface-name | ||
9 | # $2 = tty-device | ||
10 | # $3 = speed | ||
11 | # $4 = local-IP-address | ||
12 | # $5 = remote-IP-address | ||
13 | # $6 = ipparam | ||
14 | |||
15 | if [[ ${USEPEERDNS} ]] | ||
16 | then | ||
17 | |||
18 | if [ -x /sbin/resolvconf ] | ||
19 | then | ||
20 | conf="# Generated by ppp for $1\n" | ||
21 | [[ -n ${DNS1} ]] && conf="${conf}nameserver ${DNS1}\n" | ||
22 | [[ -n ${DNS2} ]] && conf="${conf}nameserver ${DNS2}\n" | ||
23 | echo -e "$conf" | resolvconf -a "$1" | ||
24 | else | ||
25 | # add the server supplied DNS entries to /etc/resolv.conf | ||
26 | # (taken from debian's 0000usepeerdns) | ||
27 | |||
28 | # follow any symlink to find the real file | ||
29 | REALRESOLVCONF=$(readlink --canonicalize /etc/resolv.conf) | ||
30 | |||
31 | if [[ ${REALRESOLVCONF} != /etc/ppp/resolv.conf ]] | ||
32 | then | ||
33 | # merge the new nameservers with the other options from the old configuration | ||
34 | { | ||
35 | grep --invert-match '^nameserver[[:space:]]' ${REALRESOLVCONF} | ||
36 | cat /etc/ppp/resolv.conf | ||
37 | } > ${REALRESOLVCONF}.tmp | ||
38 | |||
39 | # backup the old configuration and install the new one | ||
40 | cp -dpP ${REALRESOLVCONF} ${REALRESOLVCONF}.pppd-backup | ||
41 | mv ${REALRESOLVCONF}.tmp ${REALRESOLVCONF} | ||
42 | |||
43 | # correct permissions | ||
44 | chmod 0644 /etc/resolv.conf | ||
45 | chown root:root /etc/resolv.conf | ||
46 | fi | ||
47 | fi | ||
48 | fi | ||
49 | |||
50 | if [ -f /etc/conf.d/net.$1 ] | ||
51 | then | ||
52 | /etc/rc.d/init.d/network start $1 > /dev/null | ||
53 | fi | ||
54 | |||
55 | [ -f /etc/ppp/ip-up.local ] && . /etc/ppp/ip-up.local "$@" |