Network janitor's log:
Thursday, December 22, 2005
Simple script to switch IPs
#!/bin/bash
# Switch IP script, v.1 - iandexter@philrice.gov.ph
CONFIG_DIR=/etc/sysconfig/network-scripts
ROOT_UID=0
ERRROR_XCD=66
ERROR_NOTROOT=67
# Run as root
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script."
exit $ERROR_NOTROOT
fi
cd $CONFIG_DIR || {
echo "Cannot change to config dir."
exit $ERROR_XCD
}
if [ -z "$1" ]
then
echo "Usage: `basename $0` [afrdis|preginet]"
exit 1
else
if grep -q $1 ifcfg-eth0
then
echo "Already linked. Not switching anymore."
exit 0
else
echo "Switching to $1 link..."
cp ifcfg-eth0.$1 ifcfg-eth0
ifdown eth0
ifup eth0
ifconfig eth0
exit 0
fi
fi
0 Comments:
Post a Comment
<< Home