Sybase RC Script Example


#!/sbin/sh
#-------------------------------------
#  Sybase process start / stop
#
#  Copy to /etc/init.d
#-------------------------------------


SYBASE=/opt/sybase
export SYBASE

LD_LIBRARY_PATH=/opt/sybase/lib
export LD_LIBRARY_PATH


case "$1" in

'stop')

#-------------------------------------
#  Sybase shutdown
#-------------------------------------

logfile=/aux/logs/K25sybase.log
user=sysoperator
ifile=/opt/sybase/interfaces
server=sybase22

pwd=`cat /opt/dba/security/pwd/token.txt`

echo "`date` Shutting down Sybase server ..." >> $logfile

eval /opt/sybase/bin/isql -S$server -I$ifile -U$user -P$pwd << finis >> $logfile

checkpoint
go  
shutdown SYB_BACKUP
go
shutdown
go

finis

sleep 3

echo "`date` Shutdown complete " >> $logfile

 ;;


'start')

#-------------------------------------
#  Sybase startup
#-------------------------------------

# initalize variables
logdir=/aux/logs
logfile=$logdir/S99sybase.log
dsfile=$logdir/ds-boot.log
dscmd="/opt/sybase/install/startserver -f /opt/sybase/install/RUN_$server"
bsfile=$logdir/bs-boot.log
bscmd="/opt/sybase/install/startserver -f opt/sybase/install/RUN_SYB_BACKUP"
tstamp=`date '+%y%m%d%H%M'`
server=sybase22

echo "Startup of Sybase server on `date`" >>$logfile

# clean archive dir, 180 days old

if test -f $logdir/*.log ; then
   /usr/bin/find $logdir -mtime +180 -exec rm {} \;
fi   


# move log file to archive directory

mv $SYBASE/install/SYB_BACKUP.log $logdir/SYB_BACKUP.$tstamp.log
mv $SYBASE/install/$server.log $logdir/$server.$tstamp.log

sleep 10

# -----------------------------
# Start data server
# -----------------------------

su - sybase -c "$dscmd > $dsfile"

sleep 3

# -----------------------------
# Start backup server
# -----------------------------

su - sybase -c "$bscmd > $bsfile"

echo "Startup of Sybase completed on `date`" >>$logfile

    ;;


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

exit 0