home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20120521.etc.tar.gz / bradford.20120521.etc.tar / etc / ppp / ip-up < prev    next >
Text File  |  2006-06-02  |  6KB  |  244 lines

  1. #!/bin/bash
  2.  
  3. # Do not edit this file, use ip-up.local instead.
  4.  
  5. # (C) 1997-2004 SuSE Linux AG, Nuernberg, Germany
  6. # Klaus Franken 25.02.1998
  7. # Remo Behn 18.07.1998
  8. # Arvin Schnell 28.02.2002
  9. # Ludwig Nussel 26.02.2004
  10. # Send suggestions and comments to http://www.suse.de/feedback/
  11.  
  12. BASENAME=${0##*/}
  13. INTERFACE=$1
  14. DEVICE=$2
  15. SPEED=$3
  16. LOCALIP=$4
  17. REMOTEIP=$5
  18. IPPARAM=$6
  19.  
  20. # send all output to syslog
  21. exec > >(logger -p security.notice -t "$BASENAME") 2>&1
  22.  
  23. if [ -z "$REMOTEIP" ]; then
  24.     echo "Usage: $0 <INTERFACE> <DEVICE> <SPEED> <LOCALIP> <REMOTEIP>"
  25.     exit 1
  26. fi
  27.  
  28. TERM=raw
  29. export TERM
  30.  
  31. # smpppd-1.14 passes two single quoted paramters in $IPPARAM. The first one is
  32. # the ifcfg filename, the second the provider.
  33. parse_ipparam()
  34. {
  35.     case "$IPPARAM" in
  36.         \'ifcfg-*) ;;
  37.         *) return ;;
  38.     esac
  39.     eval set -- $IPPARAM
  40.     [ "$#" -ne 2 ] && return
  41.     
  42.     ifcfg=${1##ifcfg-}
  43.     provider=$2
  44.  
  45.     export ifcfg provider
  46. }
  47.  
  48. # Automatic configuration of your resolv.conf for peer supplied DNS addresses
  49. # when using the 'usepeerdns' option ('ms-get-dns' for ipppd). Original
  50. # resolv.conf is restored when ip-down is called by pppd when the link goes
  51. # down.
  52. add_nameservers()
  53. {
  54.     [ -z "$USEPEERDNS" ] && return
  55.  
  56.     if [ -z "$isdn" ]; then
  57.         [ ! -f /etc/ppp/resolv.conf ] && return
  58.         /sbin/modify_resolvconf modify -s pppd -p pppd -e "$INTERFACE" \
  59.             -f /etc/ppp/ip-up -n "$DNS1 $DNS2" -t - <<-EOT
  60.             If you do not want the pppd to change your nameserver settings
  61.             set MODIFYDNS=no in the config file for this provider in
  62.             /etc/sysconfig/network/providers/ and ensure that the option
  63.             usepeerdns is not set in /etc/ppp/options.
  64.         EOT
  65.     else
  66.         [ -z "$MS_DNS1" ] && return
  67.         /sbin/modify_resolvconf modify -s ipppd -p ipppd -e "$INTERFACE" \
  68.             -f /etc/ppp/ip-up -n "$MS_DNS1 $MS_DNS2" -t - <<-EOT
  69.             If you do not like the ipppd to change your nameserver
  70.             settings remove the option MODIFYDNS for this provider
  71.         EOT
  72.     fi
  73.  
  74. }
  75.  
  76. # restore the original resolv.conf saved when ip-up was called by the
  77. # pppd which uses the `usepeerdns' option and resolv.conf was modified
  78. # for the supplied dns server adresses.
  79. restore_nameservers()
  80. {
  81.     [ -z "$USEPEERDNS" ] && return
  82.  
  83.     if [ -z "$isdn" ]; then
  84.         [ ! -f /etc/ppp/resolv.conf ] && return
  85.         /sbin/modify_resolvconf restore -s pppd -e "$INTERFACE"
  86.     else
  87.         [ -z "$MS_DNS1" ] && return
  88.         /sbin/modify_resolvconf restore -s ipppd -e "$INTERFACE"
  89.     fi
  90. }
  91.  
  92. # using this function currently breaks Dial On Demand setups, because
  93. # ifdown finally removes the device so the function calls are disabled
  94. # now (bug #39048)
  95. # run ifdown script to execute additional scripts
  96. run_ifdown()
  97. {
  98.     [ -z "$ifcfg" -o -z "$INTERFACE" ] && return
  99.      /sbin/ifdown $ifcfg $INTERFACE -o dhcp 2>&1 | logger -t ifdown
  100. }
  101.  
  102. # run ifup script to execute additional scripts
  103. run_ifup()
  104. {
  105.     [ -z "$ifcfg" -o -z "$INTERFACE" ] && return
  106.      /sbin/ifup $ifcfg $INTERFACE -o dhcp 2>&1 | logger -t ifup
  107. }
  108.  
  109. # start SuSEfirewall2 if configured
  110. # TODO: let ifup/ifdown handle this
  111. start_firewall()
  112. {
  113.     test "$FIREWALL" = "no" && return
  114.  
  115.     if /sbin/chkconfig --check SuSEfirewall2_setup; then
  116.         /sbin/SuSEfirewall2 start
  117.     fi
  118. }
  119.  
  120. # /etc/ppp/poll.tcpip as shipped is able to set the system clock using
  121. # ntpdate (see the NTPD_INITIAL_NTPDATE setting in
  122. # /etc/sysconfig/ntp). It supports fetchmail with a system-wide
  123. # /etc/fetchmailrc and can use UUCP to fetch mail over TCP/IP, provided
  124. # that UUCP is configured properly. Last not least it also calls
  125. # sendmail to send any queued mail
  126. run_poll_tcpip()
  127. {
  128.     [ "$RUN_POLL_TCPIP" = "no" ] && return
  129.  
  130.     /etc/ppp/poll.tcpip | logger -p security.notice -t poll.tcpip > /dev/null &
  131. }
  132.  
  133. isdn_restartinterface()
  134. {
  135.     [ -z "$isdn" ] && return;
  136.  
  137.     LINK_OPT=""
  138.     test "$DYNAMICIP" = "yes" && LINK_OPT="$LINK_OPT dynamic on"
  139.     /sbin/ip addr flush dev $INTERFACE
  140.     /sbin/ip link set $INTERFACE down
  141.     /sbin/ip link set $INTERFACE up $LINK_OPT
  142.     /sbin/ip addr add dev $INTERFACE local $IPADDR peer $PTPADDR
  143.  
  144.     # set routes from /etc/sysconfig/network/routes (only for dod)
  145.     if [ "$DIALMODE" = "auto" ] ; then
  146.         /etc/sysconfig/network/scripts/ifup-route $INTERFACE
  147.     fi
  148. }
  149.  
  150.  
  151. parse_ipparam
  152.  
  153.  
  154. isdn="" # non-zero if called by ipppd
  155. case "$INTERFACE" in
  156.     ippp*)
  157.     [ -z "$ifcfg" ] && ifcfg="$INTERFACE"
  158.     isdn=yes
  159.     ;;
  160.     *)
  161.     ;;
  162. esac
  163.  
  164. #########
  165. # TODO: let ifup/ifdown handle this
  166.  
  167. # config file common to all interfaces, needed for global firewall setting
  168. . /etc/sysconfig/network/config
  169.  
  170. # interface specific config file if any
  171. if [ -n "$ifcfg" -a -r /etc/sysconfig/network/ifcfg-"$ifcfg" ]; then
  172.     . /etc/sysconfig/network/ifcfg-"$ifcfg"
  173. fi
  174.  
  175. #########
  176.  
  177. case "$BASENAME" in
  178.     ip-up)
  179.     add_nameservers
  180.     
  181.     # ip_resend hook
  182.     test "$IP_RESEND" = "yes" -a -x /usr/sbin/ip_resend_wakeup && \
  183.         /usr/sbin/ip_resend_wakeup -m $LOCALIP -o $INTERFACE
  184.  
  185.     start_firewall
  186.  
  187.     run_poll_tcpip
  188.  
  189.     # call ip-up.local if it exists and is executable:
  190.     if test -x /etc/ppp/ip-up.local ; then
  191.         /etc/ppp/ip-up.local "$@" | logger -p security.notice -t ip-up.local > /dev/null &
  192.     fi
  193.  
  194.     # run additional scripts if they exist
  195.     if [ -d /etc/ppp/ip-up.d ]; then
  196.         for SCRIPT in /etc/ppp/ip-up.d/*; do
  197.             [ -d $SCRIPT -o ! -x $SCRIPT ] && continue;
  198.             # ignore backup files and leftovers from rpm
  199.             case $SCRIPT in
  200.                 *.rpmsave|*.rpmnew|*rpmorig|*~) continue ;;
  201.             esac
  202.             $SCRIPT "$@" | logger -p security.notice -t $SCRIPT > /dev/null &
  203.         done
  204.     fi
  205.  
  206.     #run_ifup
  207.  
  208.     ;;
  209.     ip-down)
  210.  
  211.     restore_nameservers
  212.  
  213.     isdn_restartinterface
  214.     
  215.     start_firewall
  216.  
  217.     # call ip-down.local if it exists and is executable:
  218.     if test -x /etc/ppp/ip-down.local ; then
  219.         /etc/ppp/ip-down.local "$@" | logger -p security.notice -t ip-down.local > /dev/null &
  220.     fi
  221.  
  222.     # ip_resend hook
  223.     test "$IP_RESEND" = "yes" -a -x /usr/sbin/ip_resend && \
  224.         /usr/sbin/ip_resend -o $INTERFACE $IP_RESEND_PARAMETER
  225.  
  226.     # run additional scripts if they exist
  227.     if [ -d /etc/ppp/ip-down.d ]; then
  228.         for SCRIPT in /etc/ppp/ip-down.d/*; do
  229.             [ -d $SCRIPT -o ! -x $SCRIPT ] && continue;
  230.             # ignore backup files and leftovers from rpm
  231.             case $SCRIPT in
  232.                 *.rpmsave|*.rpmnew|*rpmorig|*~) continue ;;
  233.             esac
  234.             $SCRIPT "$@" | logger -p security.notice -t $SCRIPT > /dev/null &
  235.         done
  236.     fi
  237.  
  238.     #run_ifdown
  239.  
  240.     ;;
  241.     *)
  242.     ;;
  243. esac
  244.