Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > main-release > by-pkgid > cdc22c1bfdc1be9e5ae8f6d42694bf63 > files > 18

isdn4net-1.4.6-19mdv2010.1.noarch.rpm

#!/bin/sh

# ifup-isdn

PATH="/sbin:/usr/sbin:/bin:/usr/bin"

echo "Activating ISDN device: $1"

# Check that ISDN module is up
# `lsmod |grep isdn`  || echo "ISDN module not loaded! Exiting" ; exit

# Set configname = device
CONFIG=$1

# Main I4L configuration, if available
if [ -f /etc/sysconfig/isdn ] ; then
    echo "Loading global settings: /etc/sysconfig/isdn"
    . /etc/sysconfig/isdn
fi

# Set ISDN profile directory, if available
if [ -f $I4L_PROFILEDIR ] ; then
	$I4L_PROFILEDIR="/etc/isdn/profile"
fi

# Default config, if available
if [ -f "$I4L_PROFILEDIR/isdn.default" ] ; then
	echo "Loading default settings: $I4L_PROFILEDIR/isdn.default"
	. "$I4L_PROFILEDIR/isdn.default"
fi

# Device net config
echo "Loading network settings: $CONFIG"
. $CONFIG

# Custom link config, if available
I4L_PROFILE=`cat /etc/isdn/profile/isdn.map | grep $DEVICE | awk -F "=" '{print $2}' | tr -d '\"' `
if [ -f "$I4L_PROFILEDIR/link/$I4L_PROFILE" ] ; then
	echo "Loading link settings: $I4L_PROFILEDIR/link/$I4L_PROFILE"
	. "$I4L_PROFILEDIR/link/$I4L_PROFILE"
	echo "Using profile $I4L_PROFILE : $I4L_PROFILENAME"
fi

# Add device
isdnctrl addif $DEVICE

cat /proc/net/dev | grep $DEVICE >& /dev/null
if test $? -ne 0; then
    echo "$0: $DEVICE doesn't exist in /proc/net/dev"
    echo "Check ISDN hardware configuration"
    echo ""
    exit 1
fi

# define local MSN (phone number):
isdnctrl eaz $DEVICE ${I4L_LOCALMSN}

# Dialout numbers

# 1.0 config? 
if [ "$I4L_REMOTE_OUT1" != "" ] ; then
	I4L_REMOTE_OUT="$I4L_REMOTE_OUT1 $I4L_REMOTE_OUT2"	
fi 

if [ "$I4L_REMOTE_IN1" != "" ] ; then
	I4L_REMOTE_IN="$I4L_REMOTE_IN1 $I4L_REMOTE_IN2"	
fi

echo ${I4L_REMOTE_OUT} | while read out1 out2 out3 out4 out5; do
	test -z "$out1" || isdnctrl addphone $DEVICE out $out1
	test -z "$out2" || isdnctrl addphone $DEVICE out $out2	
	test -z "$out3" || isdnctrl addphone $DEVICE out $out3
	test -z "$out4" || isdnctrl addphone $DEVICE out $out4
	test -z "$out5" || isdnctrl addphone $DEVICE out $out5
done

# Dialin numbers
 
echo ${I4L_REMOTE_IN} | while read in1 in2 in3 in4 in5; do
	test -z "$in1" || isdnctrl addphone $DEVICE in $in1
	test -z "$in2" || isdnctrl addphone $DEVICE in $in2	
	test -z "$in3" || isdnctrl addphone $DEVICE in $in3
	test -z "$in4" || isdnctrl addphone $DEVICE in $in4
	test -z "$in5" || isdnctrl addphone $DEVICE in $in5
done

# the  layer-2 protocol:
isdnctrl l2_prot $DEVICE $I4L_L2

# the  layer-3 protocol:
isdnctrl l3_prot $DEVICE $I4L_L3

# encapsulation
isdnctrl encap $DEVICE $I4L_ENCAP

# secure?, on = only defined numbers are allowed to call in
isdnctrl secure $DEVICE $I4L_SECURE

# on demand (SV)
isdnctrl dialmode $DEVICE $I4L_DIALMODE

# automatic hangup if idle:
isdnctrl huptimeout $DEVICE ${I4L_IDLETIME}

# hangup before  next  charge  info?
isdnctrl chargehup $DEVICE $I4L_CHARGEHUP

# set the number of dial atempts for each number
test -z "$I4L_DIALMAX" ||
    isdnctrl dialmax $DEVICE $I4L_DIALMAX

# callback features
isdnctrl callback $DEVICE $I4L_CALLBACK
isdnctrl cbdelay $DEVICE $I4L_CBDELAY
isdnctrl cbhup $DEVICE $I4L_CBHUP

if [ -n "$SLAVE" ]; then
     isdnctrl addslave $DEVICE $SLAVE

    # define local MSN (phone number):
    isdnctrl eaz $SLAVE ${I4L_LOCALMSN}
	# Dialout numbers
	echo ${I4L_REMOTE_OUT} | while read out1 out2 out3 out4 out5; do
		test -z "$out1" || isdnctrl addphone $SLAVE out $out1
		test -z "$out2" || isdnctrl addphone $SLAVE out $out2	
		test -z "$out3" || isdnctrl addphone $SLAVE out $out3
		test -z "$out4" || isdnctrl addphone $SLAVE out $out4
		test -z "$out5" || isdnctrl addphone $SLAVE out $out5
	done

	# Dialin numbers 
	echo ${I4L_REMOTE_IN} | while read in1 in2 in3 in4 in5; do
		test -z "$in1" || isdnctrl addphone $SLAVE in $in1
		test -z "$in2" || isdnctrl addphone $SLAVE in $in2	
		test -z "$in3" || isdnctrl addphone $SLAVE in $in3
		test -z "$in4" || isdnctrl addphone $SLAVE in $in4
		test -z "$in5" || isdnctrl addphone $SLAVE in $in5
	done
	# the  layer-2 protocol:
	isdnctrl l2_prot $SLAVE $I4L_L2

	# the  layer-3 protocol:
	isdnctrl l3_prot $SLAVE $I4L_L3

	# encapsulation
	isdnctrl encap $SLAVE $I4L_ENCAP

fi


echo -n "Configuring IP device $DEVICE" 

#ifconfig ${DEVICE} ${IPADDR} pointopoint ${REMOTEADDR} netmask ${NETMASK} broadcast ${BROADCAST}
ifconfig ${DEVICE} ${IPADDR} pointopoint ${REMOTEADDR} netmask ${NETMASK} -arp -broadcast

echo -n "Final SysV network setup "

/etc/sysconfig/network-scripts/ifup-post $CONFIG

echo

exit 0