#!/bin/bash
#
#---------------------------- /etc/init.d/db2 ------------------------
# db2
#
# description: Start up the db2 service
# Source function library.
. /etc/rc.d/init.d/functions
# Application owner
USER=dwapinst
RETVAL=0
prog="db2"
start() {
echo -n $"Starting $prog:"
initlog -c "/bin/su - $USER -c 'db2start'" && success || failure
RETVAL=$?
echo ""
}
status() {
initlog -c "/bin/su - $USER -c 'db2gcf -s'" && success || failure
RETVAL=$?
echo ""
}
stop() {
echo -n $"Stopping $prog:"
# Is DB2 already stopped?
status
if [ $RETVAL -gt 0 ]; then
# Already stoped return 0
echo "Already stopped"
success
RETVAL=0
echo ""
else
# DB2 must still be running. Stop it.
initlog -c "/bin/su - $USER -c 'db2 force application all'" && success || failure
sleep 5
initlog -c "/bin/su - $USER -c 'db2stop force'" && success || failure
sleep 5
initlog -c "/bin/su - $USER -c 'db2_kill'" && success || failure
echo ""
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
sleep 3
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
RETVAL=1
;;
esac
exit $RETVAL
阅读(2685) | 评论(0) | 转发(0) |