#!/bin/sh # # (C) Copyright 1995-1999 Mike Jagdis <jaggy@purplet.demon.co.uk> # # # Configure the ippp interfaces according to the descriptions # in the configuration file. # # This script would normally be installed as /etc/rc.ippp, # /etc/init.d/ippp, /etc/rc[1-5].d/SXXippp or similar # depending on your system religion. # # The assumption is that dialds are to be used to manage the ippp # interfaces. If not the ippp interfaces should be reconfigured # afterwards as necessary. # # This should run before dialds are started and before any attempt # is made to reconfigure ippp interfaces differently. # CONFIGURABLE STUFF export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin config_file=/etc/ippp.conf # END OF CONFIGURABLE STUFF action="$1" shift links="$*" if [ -n "$BASH_VERSION" ]; then enable echo enable kill use_escapes='-e' else use_escapes='' fi start_ipppd() { link="$1" eazmsn="$2" shift; shift echo $use_escapes " $link\c" if [ "$eazmsn" = '-' ]; then eazmsn= fi ports= while [ -n "$1" ]; do case "$1" in ippp*) ports="$ports /dev/$1" # Set up this interface for syncPPP over HDLC. # Disable the hangup timeout because diald should be # managing that. (Actually I set 300 seconds just # in case diald dies with the link up...) ( isdnctrl delif "$1"; \ isdnctrl addif "$1"; \ isdnctrl encap "$1" syncppp; \ isdnctrl l2_prot "$1" hdlc; \ isdnctrl huptimeout "$1" 300; \ isdnctrl eaz "$1" "$eazmsn"; \ isdnctrl status "$1" on; \ ) > /dev/null 2>&1 # Explicitly bind the interface to the matching # syncPPP manager channel. This is essential if # any PPP options are specified. It is arguably # convenient when no options are supplied and a # single ipppd manages several links too. unit=`echo "$1" | cut -c5-` if [ -n "$unit" ]; then isdnctrl pppbind "$1" "$unit" >/dev/null 2>&1 fi if [ -n "$eazmsn" ]; then # This interface is available for incoming # connections. ifconfig "$p" 0.0.0.0 \ pointopoint 0.0.0.0 \ netmask 255.255.255.255 \ up > /dev/null 2>&1 fi ;; *) break ;; esac shift done pppopts="$*" # Diald will add host routes as appropriate. If we # let ipppd do it diald may never notice the link # come up as a result of an incoming connection # where all the traffic is to/from the local # system. i.e. our reply must go out via the # diald slip proxy. ipppd $ports -hostroute $pppopts pidfile "/var/run/ipppd.$link" } case "${action}" in start) # Set up ippp interfaces. If a configuration file # exists we read the details and apply them. if [ -f "$config_file" ]; then # Try and load compression modules before doing # anything that might load SLIP/PPP modules. modprobe bsd_comp ppp_deflate > /dev/null 2>&1 echo $use_escapes "Configuring ippp interfaces:\c" while read key args; do # Ignore blank lines and comments. case "$key" in '#'*|'') continue ;; esac if [ -z "$links" ]; then start_ipppd "$key" $args else for i in $links; do if [ "$key" = "$i" ]; then start_ipppd "$key" $args break fi done fi done < "$config_file" echo fi ;; stop) if [ -z "$links" ]; then pids=`cat /var/run/ipppd.* 2> /dev/null` else pids=`for key in $links; do cat "/var/run/ipppd.$key" done 2> /dev/null` fi if [ -z "$pids" ]; then echo "No ippp interfaces to stop" exit 0 fi kill $pids > /dev/null 2>&1 sleep 1 for retry in 1 2 3; do if kill $pids > /dev/null 2>&1; then : some still exist sleep 2 else echo "ippp interfaces stopped" break fi done ;; *) echo "usage: ippp start|stop [link ...]" exit 1 ;; esac