#!/bin/bash

#	FarSync X21 driver for Linux
#
#	Take interface down for systems without Red Hat style network config
#
#	Copyright (C) 2001 FarSite Communications Ltd.
#	www.farsite.co.uk
#
#	This program is free software; you can redistribute it and/or
#	modify it under the terms of the GNU General Public License
#	as published by the Free Software Foundation; either version
#	2 of the License, or (at your option) any later version.
#
#	File:	farifdown
#	Author:	R.J.Dunlop	<bob.dunlop@farsite.co.uk>
#
#	Revision history at end of file
#

PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin

COMPNY_DIR=/etc/farsite
CONFIG_DIR=$COMPNY_DIR/farsync

cd $CONFIG_DIR

CONFIG=$1
if [ -z "$CONFIG" ]
then
	echo usage: $0 device
	exit 1
fi

if [ ! -f $CONFIG ]
then
	CONFIG=ifcfg-$CONFIG
fi
if [ ! -f $CONFIG ]
then
	echo $0: Missing device configuration file $CONFIG_DIR/$CONFIG
fi

. $CONFIG

DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"`
OTHERSCRIPT="${CONFIG_DIR}/ifdown-${DEVICETYPE}"

if [ -x $OTHERSCRIPT ]
then
	exec $OTHERSCRIPT $CONFIG $2
fi

# Only take it down if it's marked as UP
if ifconfig ${DEVICE} 2>/dev/null | grep UP >/dev/null 2>&1
then
	ifconfig ${DEVICE} down
fi

exit 0

#
#	Revision History
#	$Log: farifdown,v $
#	Revision 1.2  2009/07/10 08:23:24  kevinc
#	Merging 1.09.04 and async branches
#	
#	Revision 1.1.1.1  2009/05/06 12:45:30  kevinc
#	
