Informix Init Script

It's been a while since I posted here.

I got tired of starting Informix by hand every time I reboot, so I wrote an init script based on my Sybase init script.

Put it in /etc/init.d/informix then do:

update-rc.d informix defaults

Don't forget to edit the three variables at the top to match your configuration.

Here it is:

#!/bin/sh
#
# Startup script for Informix Database Server
# 
# description: Informix RDBMS
# is a SQL database server.
# processname: oninit
### BEGIN INIT INFO
# Provides:          informix
# Required-Start:    $remote_fs $syslog $named
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start Informix RDBMS
# Description:       Start Informix RDBMS
### END INIT INFO
  

export INFORMIXDIR=/home/informix
export INFORMIXSERVER=demo_on
export ONCONFIG=onconfig
  

# Find the name of the script
NAME=`basename $0`
  

# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
	SU=runuser
else
	SU=su
fi
  

start() {
	INFORMIX_START=$"Starting ${NAME} service: "
	$SU informix -c $INFORMIXDIR/bin/oninit
	ret=$? 
	if [ $ret -eq 0 ]
	then
		echo "$INFORMIX_START Success."
	else
		echo "$INFORMIX_START Failed!"
                exit 1
	fi
	echo
}
  

stop() {
	echo -n $"Stopping ${NAME} service: "
	$SU informix -c "$INFORMIXDIR/bin/onmode -ky"
	ret=$?
	if [ $ret -eq 0 ]
	then
		echo "Success."
	else
		echo "Failed!"
		exit 1
	fi
        echo
}
  

restart() {
	stop
	start
}
  

case "$1" in
  

	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		restart
		;;
	*)
		echo $"Usage: $0 {start|stop|restart}"
		exit 1
esac
exit 0

I still need to automate the obnoxious license prompt when starting the dev version of SQLAnywhere, so all my databases can start automatically :)


Last modified: 2017-1-8 (日) at 1:14 pm