Start a IHS as daemon

This is my IHS script for Linux

#!/bin/sh
### BEGIN INIT INFO
# Provides: ibm-http
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 3 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop IBM HTTP Server
### END INIT INFO
#
# IBM HTTP This init.d script starts the IBM HTTP Server

# Find the name of the script
NAME=`basename $0`
ihs_Path=/opt/ibm/HTTPServer

IBMHTTPCTL="${ihs_Path}/bin/apachectl"

set -e
if [ ! -x ${ihs_Path}/bin/httpd ] ; then
echo "No IBM HTTP Server installed"
exit 0
fi

start() {
echo -n $"Starting ${NAME} service: "
$IBMHTTPCTL -k start; > /dev/null
ret=$?
if [ $ret -eq 0 ]
then
echo "${NAME} Started."
else
echo "${NAME} Starting Failed!"
exit 1
fi
echo
}

stop() {
echo -n $"Stopping ${NAME} service: "
$IBMHTTPCTL -k stop > /dev/null

ret=$?
if [ $ret -eq 0 ]
then
echo "${NAME} Stop Success."
else
echo "${NAME} Stop Failed!"
exit 1
fi
echo
}

graceful() {
echo -n $"graceful ${NAME} service: "
$IBMHTTPCTL -k graceful
ret=$?
if [ $ret -eq 0 ]
then
echo "graceful Success."
else
echo "graceful Failed!"
exit 1
fi
echo
}

restart() {
echo -n $"Restart ${NAME} service: "
$IBMHTTPCTL -k restart
ret=$?
if [ $ret -eq 0 ]
then
echo "restart Success."
else
echo "restart Failed!"
exit 1
fi
echo
}

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

Start a db2 instance as daemon

Just because I always have problem with db2 autostart I’ve decided to use this simply, fast and flexible script:


#!/bin/sh
### BEGIN INIT INFO
# Provides:          IBM-Db2-db2inst1
# Required-Start:    $local_fs $remote_fs $network $syslog sshd
# Required-Stop:     $local_fs $remote_fs $network $syslog sshd
# Default-Start:     3 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop IBM DB2 instance
### END INIT INFO
#
# IBM Db2 : This init.d script starts the db2inst1 instance

NAME=`basename $0`

instance_User=db2inst1



start() {
    echo -n $"Starting ${NAME} service: "
       $tds_start ; > /dev/null
	   su - $instance_User -c "db2start"  
    ret=$? 
    if [ $ret -eq 0 ]
    then
            echo "${NAME} Started."
    else
            echo "${NAME} Starting Failed!"
            exit 1
    fi
    echo
}

stop() {
    echo -n $"Starting ${NAME} service: "
       $tds_start ; > /dev/null
	   su - $instance_User -c "db2stop"  
    ret=$? 
    if [ $ret -eq 0 ]
    then
            echo "${NAME} Started."
    else
            echo "${NAME} Starting Failed!"
            exit 1
    fi
    echo
}

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