Skip to content

Instantly share code, notes, and snippets.

@jaehoo
Created March 13, 2015 02:42
Show Gist options
  • Save jaehoo/df65095fcc2398b52817 to your computer and use it in GitHub Desktop.
Save jaehoo/df65095fcc2398b52817 to your computer and use it in GitHub Desktop.
Jboss EAP 6 & Jboss AS 7 shell script to star/stop server as a service
#! /bin/sh
### BEGIN INIT INFO
# Provides: JBOSS
# Required-Start:
# Required-Stop:
# Default-Start: 5
# Default-Stop:
# Description: Start Jboss Aplication Server 6.2
### END INIT INFO
export JBOSS_HOME=/usr/share/jboss/jboss-eap-6.2
start(){
echo "Starting JBoss EAP..."
# If using an SELinux system such as RHEL 4, use the command below
# instead of the "su":
# eval "runuser - jboss -c '/opt/jboss/current/bin/run.sh > /dev/null 2> /dev/null &'
# if the 'su -l ...' command fails (the -l flag is not recognized by my su cmd) try:
#Jboss EAP 6.2
su -l jboss -c '$JBOSS_HOME/bin/standalone.sh > /dev/null 2> /dev/null &'
}
stop(){
echo "Stopping JBoss..."
# If using an SELinux system such as RHEL 4, use the command below
# instead of the "su":
# eval "runuser - jboss -c '/opt/jboss/current/bin/shutdown.sh -S &'
# if the 'su -l ...' command fails try
#Jboss EAP 6.2
su -l jboss -c '$JBOSS_HOME/bin/jboss-cli.sh --connect command=:shutdown'
}
restart(){
su -l jboss -c '$JBOSS_HOME/bin/jboss-cli.sh --connect --command=:reload'
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage: jboss {start|stop|restart}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment