In order for the Informix server to shut down automatically and boot automatically each time the host is restarted, DEISTER has a shell script.

1 Centos 7 or later

Create the profile file at /etc/profile.d/informix.sh adjusting PATHs and values for your installation:

Copy
export INFORMIXDIR=`grep "^informix:" /etc/passwd | awk -F: '{ print $6 }'`
export INFORMIXSERVER=`uname -n|awk -F'.' '{print $1}'`

#UTF8 Locale
export DB_LOCALE=en_us.utf8
export CLIENT_LOCALE=en_us.utf8

export DBDATE=DMY4-

#Expand abbreviated year values. Default is R.
#export DBCENTURY=C

#Set DBMONEY to evade bug 173783 in IDS 10.0XC3
export DBMONEY=.

export PATH=${PATH}:${INFORMIXDIR}/bin
export TERM=vt100

#In AIX is necessary since it uses terminfo
export TERMCAP=${INFORMIXDIR}/etc/termcap

#4GL compatibility
export LD_LIBRARY_PATH=${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql:${INFORMIXDIR}/lib/tools:${LD_LIBRARY_PATH}

Add service, create the file /etc/systemd/system/informix.service:

Copy
# Systemd informix start/stop
#
# Place this file as /etc/systemd/system/informix.service
# systemctl enable informix.service
# systemctl enable informix
#
[Unit]
Description=Informix dbsrv1
Documentation=file:/home/informix/release/en_us/0333 http://www.ibm.com/software/data/informix/library.html

[Service]
Type=forking
User=informix
Group=informix
#RemainAfterExit=yes
Environment="ENV_FILE=/etc/profile.d/informix.sh"
ExecStart=/bin/sh -a -c 'source $ENV_FILE && oninit -U $INFORMIXSERVER'
ExecStop=/bin/sh -a -c 'source $ENV_FILE && $INFORMIXDIR/bin/onmode -uky'
Restart=on-failure
RestartSec=90
TimeoutStartSec=240
StartLimitBurst=4


[Install]
WantedBy=multi-user.target
Copy
systemctl enable informix.service

2 Centos 6

Go to the following directory

Copy
cd /etc/init.d

Create a file with the name informix:

Copy
cat > informix

Paste the following code:

Copy
#!/bin/sh
#
# chkconfig: 345 99 01
# description:  IBM-Informix Database Server.
#
# Author:       DEISTER
#
# Initial release: Apr 02
# Aug 02: Added subsys lock file for Mandrake init control
# Oct 02: If variables are alredy defined, dont override them
#
# Absolutely no warranty -- use at your own risk

#
# Check the environment variables. If they are not defined
# they are automatically taken from /etc/password and from the name
# of the computer
#
[ -z "$INFORMIXDIR" ]    && \
   INFORMIXDIR=`grep "^informix:" /etc/passwd | awk -F: '{ print $6 }'`
[ -z "$INFORMIXSERVER" ] && \
   INFORMIXSERVER=`uname -n|awk -F'.' '{print $1}'`

export INFORMIXDIR INFORMIXSERVER

# It is important to configure the DbDATE environment variable since the user
# environment variables are not taken at automatic system startup. 
# And this environment variable is important for the  operation of
# client applications..
PATH=${INFORMIXDIR}/bin:${PATH}; export PATH
DB_LOCALE=es_es.8859-1; export DB_LOCALE
DBDATE=DMY4-;      export DBDATE
IFX_LARGE_PAGES=1; export IFX_LARGE_PAGES

#We put the scheduler of the SSD disks to noop
#echo noop > /sys/devices/pci0000:00/0000:00:15.0/0000:03:00.0/host1/target1:0:126/1:0:126:0/block/sdc/queue/scheduler
#echo noop > /sys/devices/pci0000:00/0000:00:17.0/0000:13:00.0/host2/target2:0:126/2:0:126:0/block/sdd/queue/scheduler

# On Linux udev and without devfsd the device permissions on /dev
# are not keep between machine reboots.
# Therefore, yu mus explicitily set the persissions each time you start
# the service on a machine reboot.
if [ -d /INFORMIXDEV ]; then
    for LINK in `ls -l /INFORMIXDEV/* | awk -F '->' '{ print $2 }'`; do
        chown --dereference informix:informix $LINK
        chmod 775 `dirname $LINK`
        chmod 660 $LINK
    done
fi

# -----------------------------------------------------------------------------
# Temporary dbspaces in RAM partition.
# If use partition in RAM for temporary dbspaces a backup of them is needed.
# Set the variable RAMDISK_BACKUP to the path where the backup is saved.
# -----------------------------------------------------------------------------

RAMDISK_BACKUP=

ramdisk_load()
{
        if [ -d /ramdisk ]; then
           if [ -f $RAMDISK_BACKUP ]; then
                echo "Inflating temp dbspaces from $RAMDISK_BACKUP"
                umask 0 ; 
                tar xfvP $RAMDISK_BACKUP
                echo "temp dbspaces are"
                echo "`ls -l /ramdisk`"
            else
                echo "No $RAMDISK_BACKUP file exists: temp dbspaces not loaded into /ramdisk"
            fi
        fi
}

ramdisk_save()
{
        if [ -d /ramdisk ]; then
           if [ ! -f $RAMDISK_BACKUP ]; then
                echo "Saving temp dbspaces into $RAMDISK_BACKUP" 
                tar cvfP $RAMDISK_BACKUP /ramdisk
                echo "Saving done" 
           else
                echo "Backup $RAMDISK_BACKUP already exists: not overwriting it"
           fi
        fi
}

# -----------------------------------------------------------------------------
# Actions
#   start | stop | status
# -----------------------------------------------------------------------------

start() {
        if [ `$INFORMIXDIR/bin/onstat 2>&- | grep -c initialized` -ne 0 ]
        then
            echo -n "Please wait while recover files for temporary dbspaces ..."
            ramdisk_load
            echo -n "Starting IBM-IDS ..."
            $INFORMIXDIR/bin/oninit
            touch /var/lock/subsys/informix
            echo "done"
        fi
}

stop() {
        if [ `$INFORMIXDIR/bin/onstat 2>&- | grep -c initialized` -eq 0 ]
        then
            echo -n "Shutting down IBM-IDS ... "
            $INFORMIXDIR/bin/onmode -ky
            rm -f /var/lock/subsys/informix
            echo -n "Please wait while save files for temporary dbspaces ..."
            ramdisk_save
            echo "done"
        fi
}

restart() {
        stop
        start
}

status() {
        if [ `$INFORMIXDIR/bin/onstat 2>&- | grep -c initialized` -ne 0 ]
        then
            echo -n "IBM-IDS is running... "
        fi
}

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

Give the following permissions:

Copy
chmod 744 informix

And add it as a service:

Copy
/sbin/chkconfig --add informix

Finally verify that the Informix server starts up correctly when restarting the host:

Copy
init 6