#!/bin/bash
 #
 # Run-level Startup script for the IBM DB2 instance
 #
 # chkconfig: 345 91 19
 # description: Startup/Shutdown IBM DB2 instance
 DB2_HOME="/opt/home/db2inst1/sqllib"
 DB2_OWNR="db2inst1"

# if the executables do not exist -- display error

if [ ! -f $DB2_HOME/adm/db2start -o ! -d $DB2_HOME ]
 then
 echo "IBM DB2 startup: cannot start"
 exit 1
 fi

# depending on parameter -- startup, shutdown, restart
 # of the instance and listener or usage display

case "$1" in
 start)
 # IBM DB2 instance startup
 echo -n "Starting IBM DB2: "
 su - $DB2_OWNR -c $DB2_HOME/adm/db2start

touch /var/lock/db2
 echo "OK"
 ;;
 stop)
 # IBM DB2 instance shutdown
 echo -n "Shutdown IBM DB2: "
 su - $DB2_OWNR -c $DB2_HOME/adm/db2stop

rm -f /var/lock/db2
 echo "OK"
 ;;
 reload|restart)
 $0 stop
 $0 start
 ;;
 *)
 echo "Usage: $0 start|stop|restart|reload"
 exit 1
 esac
 exit