Starting JOnAS as a Service on Linux

Here is a startup script for JOnAS, on Linux. It is a nice way to automatically start JOnAS when Linux reboots. It is quite trivial to write but I am sure it will turn out useful for anyone who is still not familiar with startup scripts on Linux. Call it jonas and save it in the directory /etc/init.d. You must be root to do that.

#! /bin/bash
# chkconfig: 2345 95 20
# description: Description of the script
# processname: jonas 
#
#jonas Start the jonas server.
#

NAME="Jonas 5.2.1"
JONAS_HOME=/home/test/jonas-full-5.2.1
JONAS_USER=test
LC_ALL=fr_FR
export JONAS_HOME  JONAS_USER LC_ALL
cd $JONAS_HOME/logs
case "$1" in
  start)
    echo -ne "Starting $NAME.\n"
    /bin/su $JONAS_USER -c "$JONAS_HOME/bin/jonas -bg start "
    ;;

  stop)
    echo -ne "Stopping $NAME.\n"
    /bin/su $JONAS_USER -c "$JONAS_HOME/bin/jonas stop "
    ;;

  *)
    echo "Usage: /etc/init.d/jonas {start|stop}"
    exit 1
    ;;
esac

exit 0

Continue reading