From d61760e4e34b7fa398a06a805fbde98a19452a2a Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 25 Feb 2000 15:55:27 +0000 Subject: add hdlc script from hugh@toad.com --- sysconfig/network-scripts/ifup-hdlc | 173 ++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 sysconfig/network-scripts/ifup-hdlc (limited to 'sysconfig') diff --git a/sysconfig/network-scripts/ifup-hdlc b/sysconfig/network-scripts/ifup-hdlc new file mode 100644 index 00000000..63cfa92c --- /dev/null +++ b/sysconfig/network-scripts/ifup-hdlc @@ -0,0 +1,173 @@ +#!/bin/sh +# +# ifup-hdlc -- Interface config script for up'ing HDLC devices +# by ||ugh Daniel 2000/02/18 +# Copyright (C) 2000, under the terms of the GPLv2 +# portions of this code are from the ifup script +# +# RCSID $Id: ifup-hdlc,v 1.1 2000/02/25 15:55:27 notting Exp $ +# +# + +# +# This script is called via network-scripts/ifup's OTHERSCRIPT mechanism +# Tested and found working for LMC cards on RedHat-6.1 systems. + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +cd /etc/sysconfig/network-scripts +. network-functions + +need_hostname + +CONFIG=$1 + +[ -z "$CONFIG" ] && { + echo "usage: ifup-hdlc " >&2 + exit 1 +} + +[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG +[ -f "$CONFIG" ] || { + echo "$0: no settings file for " >&2 + exit 1 +} + +if [ $UID != 0 ]; then + if [ -x /usr/sbin/usernetctl ]; then + if /usr/sbin/usernetctl $CONFIG report ; then + exec /usr/sbin/usernetctl $CONFIG up + fi + fi + echo "Users cannot control this device." >&2 + exit 1 +fi + +source_config + +if [ "foo$2" = "fooboot" -a "${ONBOOT}" = "no" ]; then + exit +fi + +DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"` +REALDEVICE=`echo $DEVICE | sed 's/:.*//g'` +if echo $DEVICE | grep -q ':' ; then + ISALIAS=yes + else + ISALIAS=no +fi + +if [ -z "${DEVICE}" ] ; then + # Sysadmin must state driver device file + # FIXUP: this could/should come from the command line argument + echo "$0: Error: no DEVICE= setting in ./$CONFIG" >&2 + exit 1 +fi + +if [ -z "${IPADDR}" ] ; then + # Sysadmin must state our ends IP address in the config file + echo "$0: Error: no IPADDR= setting in ./$CONFIG" >&2 + exit 1 +fi + +if [ -z "${POINTOPOINT}" ] ; then + # Sysadmin must state other ends IP address in the config file + echo "$0: Error: no POINTOPOINT= setting in ./$CONFIG" >&2 + exit 1 +fi + +# +# WARNING: this currently only works for LMC cards... +# FIXUP: we need a general interface for all cards on this... +# hdlcctl -i DEV --interface DEV --linkencap=cisco --status # etc. +if [ -n "${LINKENCAP}" ]; then + # The sysadmin needs to explictly set the line line encapsulation + # Possbile values: cisco, syncppp, ??? + PATH=${PATH}:/usr/local/sbin + if [ -z "`type -path lmcctl`" ]; then + # Can't find the + echo "$0: Error: can't find the lmcctl sbinary command" >&2 + exit 1 + fi + case "${LINKENCAP}" in + "syncppp") + /sbin/ifconfig ${DEVICE} down + lmcctl -i ${DEVICE} -P + retval=$? + if [ $retval -ne 0 ]; then + # Something failed + echo "$0: Failed: could not set the requested line encap (${LINKENCAP}) on ${DEVICE}, error number ${retval}." >&2 + fi + ;; + "cisco") + /sbin/ifconfig ${DEVICE} down + lmcctl -i ${DEVICE} -p + retval=$? + if [ $retval -ne 0 ]; then + # Something failed + echo "$0: Failed: could not set the requested line encap (${LINKENCAP}) on ${DEVICE}, error number ${retval}." >&2 + fi + ;; + *) + # Unknown link encapsulation error + echo "$0: Error: LINKENCAP type (${LINKENCAP}) unknown." >&2 + exit 1 + esac +fi + +# Warning: this block of code is, by nature, vendor specific. +if [ -n "${LMCCTL}" ]; then + # The user wants to run a LMC (www.lanmedia.com) cards control command + PATH=${PATH}:/usr/local/sbin + if [ -z "`type -path lmcctl`" ]; then + # Can't find the + echo "$0: Error: can't find the lmcctl sbinary command" >&2 + exit 1 + fi + /sbin/ifconfig ${DEVICE} down + lmcctl -i ${DEVICE} ${LMCCTL} + retval=$? + if [ $retval -ne 0 ]; then + # Something went wrong + echo "$0: Error: The LMCCTL for ${DEVICE} failed, returning ${retval}" >&2 + exit ${retval} + fi +fi + +# is this device available? (this catches PCMCIA devices for us) +/sbin/ifconfig ${REALDEVICE} 2>&1 | grep -s "not found" > /dev/null +if [ "$?" = "0" ]; then + echo "Delaying ${DEVICE} initialization due to missing device." + exit 1 +fi + +/sbin/ifconfig ${DEVICE} up ${IPADDR} pointopoint ${POINTOPOINT} netmask 255.255.255.255 +retval=$? + +if [ ${retval} -ne 0 ]; then + # The ifconfig failed, report it to the poor sysadmin + echo "$0: Failure: ifconfig of ${DEVICE} failed with a return value of ${retval}" >&2 + exit ${retval} +fi + +. /etc/sysconfig/network + +if [ "${GATEWAY}" != "" ]; then + if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then + # set up default gateway + route add default gw ${GATEWAY} ${DEVICE} + retval=$? + if [ ${retval} -ne 0 ]; then + # The g + echo "$0: Error: failed to install the default route on ${DEVICE}" >&2 + exit ${retval} + fi + DEFGW=${GATEWAY} + fi +fi + +if [ "$IPX" = yes ]; then + /etc/sysconfig/network-scripts/ifup-ipx $DEVICE +fi + +exec /etc/sysconfig/network-scripts/ifup-post $CONFIG -- cgit v1.2.1