Magellan Linux

Diff of /trunk/ppp/ip-up

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 795 by niro, Sat Aug 18 18:50:53 2007 UTC revision 796 by niro, Mon May 11 09:39:21 2009 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
 # $Header: /root/magellan-cvs/src/ppp/ip-up,v 1.1 2007-08-18 18:50:53 niro Exp $  
 #  
 # This script is run by pppd when there's a successful ppp connection.  
 #  
2    
3  # the following parameters are available:  # This script is run by pppd after the link is established.
4  # $1 = interface-name  # It executes all the scripts available in /etc/ppp/ip-up.d directory,
5  # $2 = tty-device  # with the following parameters:
6    # $1 = interface name (e.g. ppp0)
7    # $2 = tty device
8  # $3 = speed  # $3 = speed
9  # $4 = local-IP-address  # $4 = local IP address
10  # $5 = remote-IP-address  # $5 = remote IP address
11  # $6 = ipparam  # $6 = ipparam (user specified parameter, see man pppd)
12    
13  if [[ ${USEPEERDNS} ]]  cd /etc/ppp/ip-up.d || exit
14  then  
15    for SCRIPT in *.sh ; do
16   if [ -x /sbin/resolvconf ]   . ./"${SCRIPT}" "$@"
17   then  done
  conf="# Generated by ppp for $1\n"  
  [[ -n ${DNS1} ]] && conf="${conf}nameserver ${DNS1}\n"  
  [[ -n ${DNS2} ]] && conf="${conf}nameserver ${DNS2}\n"  
  echo -e "$conf" | resolvconf -a "$1"  
  else  
  # add the server supplied DNS entries to /etc/resolv.conf  
  # (taken from debian's 0000usepeerdns)  
   
  # follow any symlink to find the real file  
  REALRESOLVCONF=$(readlink --canonicalize /etc/resolv.conf)  
   
  if [[ ${REALRESOLVCONF} != /etc/ppp/resolv.conf ]]  
  then  
  # merge the new nameservers with the other options from the old configuration  
  {  
  grep --invert-match '^nameserver[[:space:]]' ${REALRESOLVCONF}  
  cat /etc/ppp/resolv.conf  
  } > ${REALRESOLVCONF}.tmp  
   
  # backup the old configuration and install the new one  
  cp -dpP ${REALRESOLVCONF} ${REALRESOLVCONF}.pppd-backup  
  mv ${REALRESOLVCONF}.tmp ${REALRESOLVCONF}  
   
  # correct permissions  
  chmod 0644 /etc/resolv.conf  
  chown root:root /etc/resolv.conf  
  fi  
  fi  
 fi  
   
 if [ -f /etc/conf.d/net.$1 ]  
 then  
  /etc/rc.d/init.d/network start $1 > /dev/null  
 fi  
   
 [ -f /etc/ppp/ip-up.local ] && . /etc/ppp/ip-up.local "$@"  

Legend:
Removed from v.795  
changed lines
  Added in v.796