Skip to content

Instantly share code, notes, and snippets.

@efann
Created October 14, 2014 21:27
Show Gist options
  • Save efann/f9e87afca7f0a8bf5de5 to your computer and use it in GitHub Desktop.
Save efann/f9e87afca7f0a8bf5de5 to your computer and use it in GitHub Desktop.
Apache Derby Server Startup Script
#!/bin/sh
#
# Startup script for Derby, the database server
#
# chkconfig: 345 90 10
# description: Derby is the database server
# processname: derby
# pidfile: /var/run/derby.pid
if [ -z "$DERBY_USER" ]; then
DERBY_USER="apachederby"
fi
if ! grep -qai "$DERBY_USER" /etc/passwd; then
echo "$DERBY_USER is not a user. Please create a user account first"
exit 1
fi
RETVAL=0
# start and stop functions
start() {
echo -n "Starting derby: "
# We'll see if we don't have to change to the directory.
# su -l $DERBY_USER -c 'cd /opt/Apache/db-derby-10.9.1.0-lib/lib;nohup java -jar derbyrun.jar server start -h 0.0.0.0 &'
su -l $DERBY_USER -c 'nohup java -jar /opt/Apache/db-derby-10.9.1.0-lib/lib/derbyrun.jar server start -h 0.0.0.0 &'
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/derby
return $RETVAL
}
stop() {
echo -n "Stopping derby: "
su -l $DERBY_USER -c 'nohup java -jar /opt/Apache/db-derby-10.9.1.0-lib/lib/derbyrun.jar server shutdown &'
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/derby /var/run/derby.pid
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
# Ugly hack
# We should really make sure derby
# is stopped before leaving stop
sleep 2
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment