The JBoss ON server, storage node and agent can be managed and run as a SysV style init service on Red Hat Enterprise Linux using the following example:
Create a initalization scipt /etc/init.d/jboss-on:
#!/bin/sh
#
# Example Red Hat JBoss Operations Network init script
#
chkconfig: - 95 20
description: Red Hat JBoss Operations Network rhqctl services
processname: standalone.sh
#
#
# This is an example script that can be used with a SysV style
init service which starts a JBoss ON server, storage node, and
agent using the rhqctl script provided by the JBoss ON server
# installation.
prog="`basename "$0"`"
# If available, the following files will be sourced, in order, for
configuration. This means that if the same value is defined in a later
file, it will override the one specified in an earlier one:
#
/etc/jboss-on.conf
/etc/jboss-on/${prog}.conf
#
# The following environment variables can be defined:
#
# RHQ_HOME -- Defaults to /opt/jboss/jboss-on
# RHQ_SERVER_HOME -- Defaults to RHQ_HOME/jon-server-*
# RHQ_AGENT_HOME -- Defaults to RHQ_HOME/rhq-agent
# RHQ_JAVA_HOME -- Defaults to /usr
# RHQ_USER -- Defaults to jonadmin
#
# If available, source environment variables for the service
# Global defaults/settings
[ -r "/etc/jboss-on.conf" ] && . "/etc/jboss-on.conf"
# Settings specific to this service
[ -r "/etc/jboss-on/${prog}.conf" ] && . "/etc/jboss-on/${prog}.conf"
# If not yet set, use some reasonable defaults:
[ -z "${RHQ_HOME}" ] && RHQ_HOME='/opt/jboss/jboss-on'
[ -z "${RHQ_SERVER_HOME}" ] && RHQ_SERVER_HOME="`eval echo "${RHQ_HOME}/jon-server-"*`"
[ -z "${RHQ_AGENT_HOME}" ] && RHQ_AGENT_HOME="${RHQ_HOME}"'/rhq-agent'
[ -z "${RHQ_JAVA_HOME}" ] && RHQ_JAVA_HOME='/usr'
[ -z "${RHQ_USER}" ] && RHQ_USER=jonadmin
# We have to export these variables so that they are available to child
# processes.
export RHQ_SERVER_HOME
export RHQ_AGENT_HOME
export RHQ_JAVA_HOME
# This is a convenient function that invokes rhqctl
rhqctl() {
RHQCTL_SCRIPT="${RHQ_SERVER_HOME}/bin/rhqctl"
[ ! -x "${RHQCTL_SCRIPT}" ] && {
echo >&2 "${RHQCTL_SCRIPT}"' was not found or is not executable.'
exit 2
}
if [ -n "${RHQ_USER}" -a "$(whoami)" != "${RHQ_USER}" ]; then
CMD="su -m ${RHQ_USER} -c '\"${RHQCTL_SCRIPT}\" $@'"
else
CMD="\"${RHQCTL_SCRIPT}\" $@"
fi
eval ${CMD}
}
# We invoke rhqctl differently if start or stop is used so we need this
# case statement to determine what should happen.
case "$1" in
start)
# Because rhqctl is so chatty/verbose we redirect standard output to
# null so we do not see it during system start and stop.
# Additionally, we invoke it in the background as it can block for
# some time during start.
rhqctl "$@" >/dev/null &
;;
stop)
# Because rhqctl is so chatty/verbose we redirect standard output to
# null so we do not see it during system start and stop.
rhqctl "$@" >/dev/null
;;
*)
# Assuming we are not starting or stopping, we will display complete
# output.
rhqctl "$@"
;;
esac
#!/bin/sh
#
# Example Red Hat JBoss Operations Network init script
#
# chkconfig: - 95 20
# description: Red Hat JBoss Operations Network rhqctl services
# processname: standalone.sh
#
#
# This is an example script that can be used with a SysV style
# init service which starts a JBoss ON server, storage node, and
# agent using the rhqctl script provided by the JBoss ON server
# installation.
prog="`basename "$0"`"
# If available, the following files will be sourced, in order, for
# configuration. This means that if the same value is defined in a later
# file, it will override the one specified in an earlier one:
#
# /etc/jboss-on.conf
# /etc/jboss-on/${prog}.conf
#
# The following environment variables can be defined:
#
# RHQ_HOME -- Defaults to /opt/jboss/jboss-on
# RHQ_SERVER_HOME -- Defaults to RHQ_HOME/jon-server-*
# RHQ_AGENT_HOME -- Defaults to RHQ_HOME/rhq-agent
# RHQ_JAVA_HOME -- Defaults to /usr
# RHQ_USER -- Defaults to jonadmin
#
# If available, source environment variables for the service
# Global defaults/settings
[ -r "/etc/jboss-on.conf" ] && . "/etc/jboss-on.conf"
# Settings specific to this service
[ -r "/etc/jboss-on/${prog}.conf" ] && . "/etc/jboss-on/${prog}.conf"
# If not yet set, use some reasonable defaults:
[ -z "${RHQ_HOME}" ] && RHQ_HOME='/opt/jboss/jboss-on'
[ -z "${RHQ_SERVER_HOME}" ] && RHQ_SERVER_HOME="`eval echo "${RHQ_HOME}/jon-server-"*`"
[ -z "${RHQ_AGENT_HOME}" ] && RHQ_AGENT_HOME="${RHQ_HOME}"'/rhq-agent'
[ -z "${RHQ_JAVA_HOME}" ] && RHQ_JAVA_HOME='/usr'
[ -z "${RHQ_USER}" ] && RHQ_USER=jonadmin
# We have to export these variables so that they are available to child
# processes.
export RHQ_SERVER_HOME
export RHQ_AGENT_HOME
export RHQ_JAVA_HOME
# This is a convenient function that invokes rhqctl
rhqctl() {
RHQCTL_SCRIPT="${RHQ_SERVER_HOME}/bin/rhqctl"
[ ! -x "${RHQCTL_SCRIPT}" ] && {
echo >&2 "${RHQCTL_SCRIPT}"' was not found or is not executable.'
exit 2
}
if [ -n "${RHQ_USER}" -a "$(whoami)" != "${RHQ_USER}" ]; then
CMD="su -m ${RHQ_USER} -c '\"${RHQCTL_SCRIPT}\" $@'"
else
CMD="\"${RHQCTL_SCRIPT}\" $@"
fi
eval ${CMD}
}
# We invoke rhqctl differently if start or stop is used so we need this
# case statement to determine what should happen.
case "$1" in
start)
# Because rhqctl is so chatty/verbose we redirect standard output to
# null so we do not see it during system start and stop.
# Additionally, we invoke it in the background as it can block for
# some time during start.
rhqctl "$@" >/dev/null &
;;
stop)
# Because rhqctl is so chatty/verbose we redirect standard output to
# null so we do not see it during system start and stop.
rhqctl "$@" >/dev/null
;;
*)
# Assuming we are not starting or stopping, we will display complete
# output.
rhqctl "$@"
;;
esac
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Change the permissions on the file so it can be executed:
chmod +x /etc/init.d/jboss-on
chmod +x /etc/init.d/jboss-on
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Add the initalization script to chkconfig:
sudo chkconfig --add /etc/init.d/jboss-on
sudo chkconfig --add /etc/init.d/jboss-on
Copy to ClipboardCopied!Toggle word wrapToggle overflow
To indicate that you intend for the script to run system startup and stop during shutdown:
sudo chkconfig jboss-on on
sudo chkconfig jboss-on on
Copy to ClipboardCopied!Toggle word wrapToggle overflow
To override the default values for RHQ_HOME, RHQ_SERVER_HOME, RHQ_AGENT_HOME, RHQ_JAVA_HOME and RHQ_USER, create the service configuration file /etc/jboss-on.conf or /etc/jboss-on/<SERVICE NAME>.conf with your specific values:
RHQ_HOME=/usr/share/jboss-on
RHQ_USER=jbosson
RHQ_HOME=/usr/share/jboss-on
RHQ_USER=jbosson
Copy to ClipboardCopied!Toggle word wrapToggle overflow