Informix Startup/Shutdown Script
Posted in 1997
Thuc
I have written a script for our Informix installations here on HP-UX.
This will work with both ver 5.x and 7.x engines. It uses a data file
located in /usr/local/etc (you may choose to locate it elsewhere, change
the script if you do). The file name is instance.list. The script reads
the information from the file and starts/stops the Informix instances.
The data file should have the following format:
# Instance List for Scotch Database Instances
# VER:INFORMIXDIR:ONCONFIG:INFORMIXSERVER:START_ISTAR:INSTANCE_DESCRIPTION
7.14:/usr/informix:onconfig.db1:db1_shm:N:Test Database Instance
You may put remarks in the file like I have by putting # on the first
character on the line.
The script is in /sbin/init.d and is called informix. The script follows:
------------------------------ cut here ------------------------------------
#!/sbin/sh
#
# Informix Startup and Shutdown script. Called from Unix Startup and Shutdown
# scripts with arguments start or stop. Accesses a data file "instance.list"
# containing relevant parameters for each Informix instance. The data needs
# to be changed for each instance added or deleted from this machine. Works
# for both version 5 and 7 databases.
#
# Modified: 03/07/97 Sujit Pal
#
PATH=/sbin:/usr/sbin:/usr/binexport PATH
rval=0
set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "ERROR CODE $x"
rval=1
fi
}
case $1 in
start_msg)
echo "Starting Informix Instances"
;;
stop_msg)
echo "Shutting down Informix Instances"
;;
'start')
TERMCAP=/usr/informix/etc/termcap; export TERMCAP
cat /usr/local/etc/instance.list |
while read INST_LINE
do
if [ `echo $INST_LINE | cut -c1-1` = '#' ]
then
continue
fi
ver=`echo $INST_LINE | cut -f1 -d":" | cut -c1-1`
INFORMIXDIR=`echo $INST_LINE | cut -f2 -d":"`
ONCONFIG=`echo $INST_LINE | cut -f3 -d":"`
INFORMIXSERVER=`echo $INST_LINE | cut -f4 -d":"` START_ISTAR=`echo $INST_LINE | cut -f5 -d":"`
INSTNAME=`echo $INST_LINE | cut -f6 -d":"`
echo "Starting " $INSTNAME "(" $ONCONFIG ")"
export INFORMIXDIR ONCONFIG INFORMIXSERVER
PATH=$INFORMIXDIR/bin:$PATH; export PATH if [ $ver -eq 7 ]
then
$INFORMIXDIR/bin/oninit
else
$INFORMIXDIR/bin/tbinit
if [ $START_ISTAR = "Y" ]
then
$INFORMIXDIR/lib/sqlexecd $INFORMIXSERVER -l /tmp/$INFORMIXSERVER
fi
fi
done
set_return
;;
'stop')
TERMCAP=/usr/informix/etc/termcap; export TERMCAP
cat /usr/local/etc/instance.list |
while read INST_LINE
do
if [ `echo $INST_LINE | cut -c1-1` = '#' ]
then
continue
fi
ver=`echo $INST_LINE | cut -f1 -d":" | cut -c1-1`
INFORMIXDIR=`echo $INST_LINE | cut -f2 -d":"`
ONCONFIG=`echo $INST_LINE | cut -f3 -d":"`
INFORMIXSERVER=`echo $INST_LINE | cut -f4 -d":"` START_ISTAR=`echo $INST_LINE | cut -f5 -d":"`
INSTNAME=`echo $INST_LINE | cut -f6 -d":"`
echo "Shutting down " $INSTNAME "(" $ONCONFIG ")"
export INFORMIXDIR ONCONFIG INFORMIXSERVER
PATH=$INFORMIXDIR/bin:$PATH; export PATH if [ $ver -eq 7 ]
then
$INFORMIXDIR/bin/onmode -ky
else
$INFORMIXDIR/bin/tbmode -ky
fi
done
set_return
;;
*)
echo "usage: $0 {start|stop}"
;;
esac
exit $rval
------------------------------ cut here ------------------------------------
The script is working fine for quite some time so I can safely say it
is bug-free.
HTH
Sujit Pal