#!/bin/sh # # /etc/init.d/isdn-syncppp.init # # ISDN SyncPPP Configuration # # Copyright 1997 Peter Bieringer # # # Version: 2.02 Datum: 20.10.97 # # Return Values: 0=ok 1=Nothing to do 2=Error occurs # Changes from i # 2.00: Place route after ifconfig # 2.01: Add a second number, if given #set -x # Source function library. [ -f /etc/init.d/functions ] || exit 0 . /etc/init.d/functions # Source networking configuration. [ -f /etc/sysconfig/network ] || exit 0 . /etc/sysconfig/network # Check if networking is up. [ "$NETWORKING" = "yes" -o "$NETWORKING" = "YES" ] || exit 0 # Source ISDN Hardware Configuration [ -f /etc/sysconfig/isdn-hw ] || exit 0 . /etc/sysconfig/isdn-hw # Source ISDN SyncPPP Configuration [ -f /etc/sysconfig/isdn ] || exit 0 . /etc/sysconfig/isdn-syncppp # Check that ISDN SyncPPP is enabled [ "$ISDNSyncPPP" = "yes" -o "$ISDNSyncPPP" = "YES" ] || exit 0 # Check that the given Binary for ISDN Control exists [ -x $ISDNCTRLBIN ] || exit 0 #Get Kernel Version for module loading VERSION=`cat /proc/version | awk '{ print $3 }' ` SYSPATH="/sbin" # Check If ISDN Hardware Is Already Configured (isdn-hw.init start) if ! [ -f /var/lock/subsys/isdn-hw ] ; then echo -e "\aNo ISDN Hardware Is Configured!" exit 1 fi #set -x case "$1" in start) echo "Starte ISDN SyncPPP Service." # Already done? Look in /var/lock/subsys for isdn-syncppp if [ -f /var/lock/subsys/isdn-syncppp ] ; then echo -e "\aAlready Done!" exit 1 fi # Do you wish masquerading intranet to internet if [ "$ISDN2PRIVATE" = "yes" -o "$ISDN2PRIVATE" = "YES" ]; then # load ip_masquerading modules echo -n "Load IP-Masquerading Modules:" cd /lib/modules/${VERSION}/ipv4 for i in ${IPMASQMODULES}; do echo -n " $i" $SYSPATH/insmod $i; done echo # Firewall-Setup for Masquerading intranet to internet echo "Setup IP-Firewall Rules for Masquerading" $SYSPATH/ipfwadm -F -a m -P all -S $PRIVATEIPNETWORK/24 -D 0.0.0.0/0 -b echo fi # Create new interface 'ISDNDEVICE' echo "Add Device $ISDNFDEVICE" $ISDNCTRLBIN addif $ISDNDEVICE # Configure interface 'ISDNDEVICE' echo "Configure Device $DEVICE" # Set incoming phone-number $ISDNCTRLBIN addphone $ISDNDEVICE in $ISDNREMOTENUMBER # Set outgoing phone-number $ISDNCTRLBIN addphone $ISDNDEVICE out $ISDNREMOTENUMBER # Set second outgoing phone-number, if given if ! [ "$ISDNREMOTENUMBER2" = "" ] ; then $ISDNCTRLBIN addphone $ISDNDEVICE out $ISDNREMOTENUMBER2 fi # Set local EAZ .. $ISDNCTRLBIN eaz $ISDNDEVICE $ISDNLOCALNUMBER # for sync PPP: set Level 2 to HDLC $ISDNCTRLBIN l2_prot $ISDNDEVICE hdlc # not really necessary, 'trans' is default $ISDNCTRLBIN l3_prot $ISDNDEVICE trans # encap the IP Pakets in PPP frames $ISDNCTRLBIN encap $ISDNDEVICE syncppp # Hangup-Timeout is 600 sec. $ISDNCTRLBIN huptimeout $ISDNDEVICE $ISDNHUPTIMEOUT # Dial up 1 time maximal (isdn.dial repeats self) $ISDNCTRLBIN dialmax $ISDNDEVICE 1 # Hangup before next Charge-Info {on|off} $ISDNCTRLBIN chargehup $ISDNDEVICE $ISDNCHARGEHUP # Accept only configured phone-number $ISDNCTRLBIN secure $ISDNDEVICE on # SyncMPPP (Multi-Link)? if [ "$ISDNSyncMPPP" = "yes" -o "$ISDNSyncMPPP" = "YES" ]; then # Create New Slave Interface 'ISDNDEVICEM' $ISDNCTRLBIN addslave $ISDNDEVICE $ISDNDEVICEM # Configure slave interface 'ISDNDEVICEM' $ISDNCTRLBIN addphone $ISDNDEVICEM in $ISDNREMOTENUMBER $ISDNCTRLBIN addphone $ISDNDEVICEM out $ISDNREMOTENUMBER $ISDNCTRLBIN eaz $ISDNDEVICEM $ISDNLOCALNUMBER $ISDNCTRLBIN l2_prot $ISDNDEVICEM hdlc $ISDNCTRLBIN l3_prot $ISDNDEVICEM trans $ISDNCTRLBIN encap $ISDNDEVICEM syncppp $ISDNCTRLBIN huptimeout $ISDNDEVICEM $ISDNHUPTIMEOUT $ISDNCTRLBIN chargehup $ISDNDEVICEM $ISDNCHARGEHUP $ISDNCTRLBIN secure $ISDNDEVICEM on fi # Choose Options dynamic or static IPPPDOPTIONS="" IFCONFIGOOPTIONS="" # Dynamic IP PPP? if [ "$PPPIPDYNAMIC" = "yes" -o "$PPPIPDYNAMIC" = "YES" ]; then # Set ifconfig options for dynamic #IFCONFIGOPTIONS="10.0.0.0 pointopoint 10.0.0.0" #IFCONFIGOPTIONS="0.0.0.0 pointopoint 0.0.0.0" # Alexey means following is enough: IFCONFIGOPTIONS="0.0.0.0" # Set ipppd Options for dynamic IPPPDOPTIONS="noipdefault useifip ipcp-accept-remote" else # Set ifconfig options for static IFCONFIGOPTIONS="$PPPIPLOCAL pointopoint $PPPIPREMOTE" # Set ipppd Options for static IPPPDOPTIONS="" fi #set -x # Options for SyncMPPP if [ "$ISDNSyncMPPP" = "yes" -o "$ISDNSyncMPPP" = "YES" ]; then IPPPDOPTIONS="$IPPPDOPTIONS +mp" fi # Add option user if given [ "$PPPUSER" = "" ] || IPPPDOPTIONS="$IPPPDOPTIONS user $PPPUSER" #set -x # Configure device echo "Configure Device $DEVICE Point-to-Point" $SYSPATH/ifconfig $ISDNDEVICE $IFCONFIGOPTIONS metric 1 -arp -broadcast -allmulti # Start ipppd echo "Start ipppd" $IPPPDBIN $IPPPDOPTIONS \ -detach \ -bsdcomp \ mru 1500 \ -chap \ -vj \ -vjccomp \ -ac -pc \ debug \ /dev/ippp0 /dev/ippp1 /dev/ippp2 & # all done, set flag touch /var/lock/subsys/isdn-syncppp echo "Done!" ;; stop) echo "Stoppe ISDN SyncPPP Service." # isdn-syncppp started? if ! [ -f /var/lock/subsys/isdn-syncppp ] ; then echo -e "\aAlready Done!" exit 1 fi # Kill ipppd echo "Kill ipppd " killproc ipppd echo # Clear Default Route echo "Clear Default-Route to ISDN" $SYSPATH/route del default dev $ISDNDEVICE # Shutdown ISDN Device echo "Shutdown Device $ISDNDEVICE" $SYSPATH/ifconfig $ISDNDEVICE down # Remove ISDN Device echo "Remove Device $ISDNDEVICE" $ISDNCTRLBIN delif $ISDNDEVICE # Reconfigure back to normal if [ "$ISDN2PRIVATE" = "yes" -o "$ISDN2PRIVATE" = "YES" ]; then # Firewall-Setup Reset Rules echo "Clear Firewall IP-Masquerading Rules" $SYSPATH/ipfwadm -F -a m # unload ip_masquerading modules echo "Unload IP-Masquerading Modules:" cd /lib/modules/${VERSION}/ipv4 for i in ${IPMASQMODULES}; do echo -n " $i:" $SYSPATH/rmmod ${i%.o} done echo fi # all done, clear flag rm -f /var/lock/subsys/isdn-syncppp echo "Done!" ;; *) echo "Syntax: isdn-syncppp.init {start|stop}" exit 1 esac #set +x exit 0