This section provides an example of a script for starting, stopping, restarting, and obtaining the status of a Sybase database cluster service.
This section provides examples of basic and advanced startup scripts for an InterSystem Cache cluster service. The basic script allows you to start, stop, restart, and obtain the status of the service. The advanced script allows you to perform these tasks and, in addition, to reload the service.
To use these scripts, issue the following commands (where scriptname is the name of the file containing this script):
scriptname start—Starts the service
scriptname stop—Stops the service
scriptname restart—Retarts the service (from a stopped state)
scriptname status—Reports the status of the service
scriptname reload—Reloads the service (available with advanced script only)
![]() | Note |
|---|---|
These scripts have been contributed by the Red Hat user community; they have not been tested by Red Hat and are unsupported. |
#!/bin/bash
#
# Startup script for InterSystem Cache
# By Sherif Abdelgawad (sabdelg@redhat.com)
# Customized for Company "A"
#
# Vendor: Red Hat, Inc.
#
# By: Sherif Abdelgawad (sabdelg@redhat.com)
#
# cache: Starts the available Cache Servers
#
# Version: @(#) /etc/init.d/cache 1.2
#
# chkconfig: 345 85 15
#
# description: This script will browse through the /opt/cache/ \
# directory and launch all Cache servers configured from this location.
#
# Setting arguments which will be used
RETVAL=0
prog=cache
start() {
echo -n $"Starting $prog: "
/etc/init.d/cstart >>/var/log/intersys.log 2>&1
RETVAL=$?
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
/etc/init.d/cstop quietly >>/var/log/intersys.log 2>&1
RETVAL=0
}
status() {
STATUS=`ps aux | grep cache | wc -l`
if [ $STATUS -lt 4 ]
then
echo "Cache is Not Up"
RETVAL=3
else
echo "Cache is UP"
RETVAL=0
fi
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
$0 stop
$0 start
;;
*)
echo "*** Usage: `basename $0` {start|stop|status|restart}"
exit 1
esac
exit $RETVAL |
Example 4-1. Basic Startup Script for InterSystem Cache
#!/bin/bash
#
# Startup script for InterSystem Cache Database
# By Sherif Abdelgawad (sabdelg@redhat.com)
# Customized for Company "A"
#
# Vendor: Red Hat, Inc.
#
# By: Sherif Abdelgawad (sabdelg@redhat.com)
#
# cache: Starts the available Cache Servers
#
# Version: @(#) /etc/init.d/cache 1.2
#
# chkconfig: 345 85 15
#
# description: This script will browse through the /opt/cache/ \
# directory and launch all Cache servers configured from this location.
#
#
# Source function library.
. /etc/init.d/functions
RETVAL=0
cache=/usr/bin/cache
run=running
prog=Cache
start() {
# Check first if Cache is Running
status $cache >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL = 3 ] ; then
echo -n $"Starting $prog: "
/usr/bin/ccontrol start cache quietly >>/var/log/intersys.log 2>&1
RETVAL=$?
wait
if [ $RETVAL != 0 ] ; then
echo -n $"Error Occured while Starting"
echo_failure
echo
return $RETVAL
fi
# Double Check if Cache run Successfully
# a=`/usr/bin/ccontrol list | grep status | cut -f2 -s | cut -d":" -f2`
# echo $a
#
# if [ $a != $run ] ; then
# echo -n $"Error Occured while Starting"
# echo_failure
# echo
# return $RETVAL
# fi
touch /var/lock/subsys/cache
echo -n $"Cache Started Successfully"
echo_success
echo
return $RETVAL
fi
echo -n $"Cache is Already Started!"
echo_failure
echo
exit 1
}
stop() {
echo -n $"Stopping $prog: "
# Check first if Cache is Running
status $cache >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL != 3 ] ; then
/usr/bin/ccontrol stop cache quietly >>/var/log/intersys.log 2>&1
RETVAL=$?
if [ $RETVAL != 0 ] ; then
echo -n $"Error Occured Stopping Cache"
echo_failure
echo
return $RETVAL
fi
rm -f /var/lock/subsys/cache
echo -n $"Cache Stopped Successfully"
echo_success
echo
return $RETVAL
fi
echo -n $"Cache is Already Stopped!"
echo_failure
echo
exit 1
}
restart() {
stop
start
}
reload() {
restart
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $cache
RETVAL=$?
;;
restart)
restart
;;
*)
echo "*** Usage: `basename $0` {start|stop|status|restart|reload}"
exit 1
esac
exit $RETVAL
|
Example 4-2. Advanced Startup Script for InterSystem Cache