Sybase Init Script

I got the free Sybase server from http://www.sybase.com/linuxpromo, but it didn't come with an init script.

I modified the one I found on https://jira.jboss.org/jira/browse/JBPM-1831 to work on Debian, or any other dist, and for the latest version of Sybase.

Just put it in /etc/init.d/sybase, edit the SERVER and SYBASE vars at the top, then do:

update-rc.d sybase defaults

Here's the script:

#!/bin/sh
#
# Startup script for Sybase ASE
# 
# description: Sybase Adaptive Server Enterprise
# is a SQL database server.
# processname: dataserver
  

SYBASE=/home/sybase
SERVER=HLAGH
  

# Source environment variables.
. $SYBASE/SYBASE.sh
  

# Find the name of the script
NAME=`basename $0`
  

# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
	SU=runuser
else
	SU=su
fi
  

start() {
	SYBASE_START=$"Starting ${NAME} service: "
	$SU sybase -c ". $SYBASE/SYBASE.sh; $SYBASE/$SYBASE_ASE/install/startserver \
-f $SYBASE/$SYBASE_ASE/install/RUN_${SERVER} > /dev/null"
	ret=$? 
	if [ $ret -eq 0 ]
	then
		echo "$SYBASE_START Success."
	else
		echo "$SYBASE_START Failed!"
              exit 1
	fi
}
  

stop() {
	echo -n $"Stopping ${NAME} service: "
	$SU sybase -c ". $SYBASE/SYBASE.sh; isql -S $SERVER -U sa -P '' < \
$SYBASE/$SYBASE_ASE/upgrade/shutdown.sql > /dev/null"
	ret=$?
	if [ $ret -eq 0 ]
	then
		echo "Success."
	else
		echo "Failed!"
		exit 1
	fi
}
  

restart() {
	stop
	start
}
  

case "$1" in
  

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

Last modified: 2017-1-8 (日) at 9:14 pm