Magellan Linux

Annotation of /trunk/ppp/ip-upd-40-dns.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 796 - (hide annotations) (download) (as text)
Mon May 11 09:39:21 2009 UTC (15 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 1233 byte(s)
new ip up down from gentoo

1 niro 796 #!/bin/sh
2    
3     # Handle resolv.conf generation when usepeerdns pppd option is being used.
4     # Used parameters and environment variables:
5     # $1 - interface name (e.g. ppp0)
6     # $USEPEERDNS - set if user specified usepeerdns
7     # $DNS1 and $DNS2 - DNS servers reported by peer
8    
9     if [ "$USEPEERDNS" ]; then
10    
11     if [ -x /sbin/resolvconf ]; then
12     {
13     echo "# Generated by ppp for $1"
14     [ -n "$DNS1" ] && echo "nameserver $DNS1"
15     [ -n "$DNS2" ] && echo "nameserver $DNS2"
16     } | /sbin/resolvconf -a "$1"
17     else
18     # add the server supplied DNS entries to /etc/resolv.conf
19     # (taken from debian's 0000usepeerdns)
20    
21     # follow any symlink to find the real file
22     REALRESOLVCONF=$(readlink --canonicalize /etc/resolv.conf)
23    
24     if [ "$REALRESOLVCONF" != "/etc/ppp/resolv.conf" ]; then
25    
26     # merge the new nameservers with the other options from the old configuration
27     {
28     grep --invert-match '^nameserver[[:space:]]' $REALRESOLVCONF
29     cat /etc/ppp/resolv.conf
30     } > $REALRESOLVCONF.tmp
31    
32     # backup the old configuration and install the new one
33     cp -dpP $REALRESOLVCONF $REALRESOLVCONF.pppd-backup
34     mv $REALRESOLVCONF.tmp $REALRESOLVCONF
35    
36     # correct permissions
37     chmod 0644 /etc/resolv.conf
38     chown root:root /etc/resolv.conf
39     fi
40     fi
41    
42     fi