Problem
Is there a way to change the IP address of my server automatically in a script?
Solution
Below is a script which can be used to accomplish this. Note that later versions of UnixWare7 may not have Netscape installed but the appropriate web server configuration file can be replaced as this serves as an example.
It is also recommended to run "ifconfig net0 down" prior to running the script, assuming that "net0" is the interface you intend to change.
It is also recommended to re-boot your server after making the change or alternatively follow the steps in TA117282, "How can I change the IP address of my UnixWare 7 system without rebooting?"
----------------------------------------------------------#!/bin/sh#1st argument is the current IP address
#2nd argument is is the new IP addressoldip=$1
newip=$2HOSTS=/etc/hosts
INTERFACE=/etc/confnet.d/inet/interface
NSADMIN=/usr/ns-home/admserv/ns-admin.confcat $HOSTS | sed s/$oldip/$newip/g > /tmp/$$.hosts
cp $HOSTS $HOSTS.old
cp /tmp/$$.hosts $HOSTS
rm -f /tmp/$$.hostscat $INTERFACE | sed s/$oldip/$newip/g > /tmp/$$.interface
cp $INTERFACE $INTERFACE.old
cp /tmp/$$.interface $INTERFACE
rm -f /tmp/$$.interfaceif [ -f $NSADMIN ]
then
cat $NSADMIN | sed s/$oldip/$newip/g > /tmp/$$.nsadmin
cp $NSADMIN $NSADMIN.old
cp /tmp/$$.nsadmin $NSADMIN
rm -f /tmp/$$.nsadmin
fi
---------------------------------------------------------- See also
TA117282, "How can I change the IP address of my UnixWare 7 system without rebooting?"