Previous versions of JBoss included a scripts (like jboss_init_redhat.sh) that could be copied to /etc/init.d in order to add it as a service - so it would star
The answer marked as correct here did not work for me. On restart, you get a security error related to the usage of sudo, stating, "sorry, you must have a tty to run sudo." Further research revealed that disabling the sudo tty restriction could cause plain text exposure of passwords, so that's no good.
Here's what I ended up with and it works fine for me:
#!/bin/sh
### BEGIN INIT INFO
# Provides: jboss
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop JBoss AS v7.0.0
### END INIT INFO
#
#source some script files in order to set and export environmental variables
#as well as add the appropriate executables to $PATH
[ -r /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh
[ -r /etc/profile.d/jboss.sh ] && . /etc/profile.d/jboss.sh
case "$1" in
start)
echo "Starting JBoss AS 7.0.0"
su --session-command "${JBOSS_HOME}/bin/standalone.sh >& /dev/null &" jboss
;;
stop)
echo "Stopping JBoss AS 7.0.0"
su --session-command "${JBOSS_HOME}/bin/jboss-admin.sh --connect command=:shutdown" jboss
;;
*)
echo "Usage: /etc/init.d/jboss {start|stop}"
exit 1
;;
esac
exit 0