118 lines
3 KiB
Text
118 lines
3 KiB
Text
#!/sbin/runscript
|
|
# Copyright 1999-2012 Gentoo Foundation
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
name="JBoss AS (standalone)"
|
|
description="JBoss Application Server __JBOSS_VER__ in standalone mode"
|
|
|
|
depend() {
|
|
need net
|
|
use dns
|
|
provide jboss-as
|
|
}
|
|
|
|
init_vars() {
|
|
jboss_home="/opt/__JBOSS_NAME__"
|
|
temp_dir="/var/tmp/__JBOSS_NAME__"
|
|
pidfile="/var/run/__JBOSS_NAME__/standalone.pid"
|
|
|
|
base_dir=${SERVER_BASE_DIR:-"/var/lib/__JBOSS_NAME__"}
|
|
data_dir=${SERVER_DATA_DIR:-"${base_dir}/data"}
|
|
deploy_dir=${SERVER_DEPLOY_DIR:-"${data_dir}/content"}
|
|
|
|
config_dir=${SERVER_CONFIG_DIR:-"/etc/__JBOSS_NAME__"}
|
|
log_dir=${SERVER_LOG_DIR:-"/var/log/__JBOSS_NAME__"}
|
|
|
|
config=${SERVER_CONFIG:-"standalone.xml"}
|
|
|
|
user=${JBOSS_USER:-"jboss"}
|
|
group=${JBOSS_GROUP:-"jboss"}
|
|
startup_wait=${STARTUP_WAIT:-"60"}
|
|
shutdown_wait=${SHUTDOWN_WAIT:-"30"}
|
|
|
|
console_log="${log_dir}/console.log"
|
|
|
|
jboss_opts="-Djboss.server.base.dir=${base_dir}"
|
|
jboss_opts="${jboss_opts} -Djboss.server.config.dir=${config_dir}"
|
|
jboss_opts="${jboss_opts} -Djboss.server.data.dir=${data_dir}"
|
|
jboss_opts="${jboss_opts} -Djboss.server.log.dir=${log_dir}"
|
|
jboss_opts="${jboss_opts} -Djboss.server.temp.dir=${temp_dir}"
|
|
jboss_opts="${jboss_opts} -Djboss.server.deploy.dir=${deploy_dir}"
|
|
|
|
command="${jboss_home}/bin/standalone.sh"
|
|
command_args="${jboss_opts} --server-config ${config} ${JBOSS_OPTIONS}"
|
|
}
|
|
|
|
init_env_vars() {
|
|
# Configuration variables for JBoss script
|
|
export JAVA_HOME=`java-config --jre-home`
|
|
export JAVA_OPTS
|
|
export JBOSS_HOME=${jboss_home}
|
|
export JBOSS_PIDFILE="${pidfile}"
|
|
export LAUNCH_JBOSS_IN_BACKGROUND=1
|
|
}
|
|
|
|
start_pre() {
|
|
init_vars
|
|
init_env_vars
|
|
|
|
if [ ! -d ${base_dir} ]; then
|
|
eerror "Server base directory ${base_dir} does not exist!"
|
|
exit 2
|
|
fi
|
|
|
|
if [ ! -f "${config_dir}/${config}" ]; then
|
|
eerror "Configuration file ${config} does not exist!"
|
|
exit 2
|
|
fi
|
|
|
|
if [ ${user} = "root" ]; then
|
|
eerror "It's not a good idea to run as root!"
|
|
exit 2
|
|
fi
|
|
|
|
checkpath -d -o ${user} "${config_dir}"
|
|
checkpath -d -o ${user} "${log_dir}"
|
|
checkpath -d -o "${user}:${group}" -m750 "${data_dir}"
|
|
checkpath -d -o "${user}:${group}" -m750 "${deploy_dir}"
|
|
checkpath -d -o "${user}:${group}" -m700 "${temp_dir}"
|
|
checkpath -d -o "${user}:${group}" -m700 `dirname ${pidfile}`
|
|
|
|
checkpath -f -o ${user} "${console_log}"
|
|
cat /dev/null > "${console_log}"
|
|
}
|
|
|
|
start() {
|
|
ebegin "Starting JBoss Application Server __JBOSS_VER__"
|
|
|
|
start-stop-daemon --start --background --quiet \
|
|
--user="${user}:${group}" \
|
|
--pidfile="${pidfile}" \
|
|
--stdout "${console_log}" --stderr "${console_log}" \
|
|
--exec ${command} -- ${command_args} \
|
|
|
|
count=0; result=1
|
|
until [ $count -gt $startup_wait ]; do
|
|
grep 'JBoss AS.*started in' "$console_log" > /dev/null
|
|
if [ $? -eq 0 ] ; then
|
|
result=0
|
|
break
|
|
fi
|
|
sleep 1
|
|
let count=$count+1;
|
|
done
|
|
|
|
eend $result
|
|
}
|
|
|
|
stop() {
|
|
ebegin "Stopping JBoss Application Server __JBOSS_VER__"
|
|
init_vars
|
|
|
|
start-stop-daemon --stop --quiet \
|
|
--pidfile=${pidfile} \
|
|
--retry=TERM/${shutdown_wait}/KILL/10 \
|
|
--exec ${command} -- ${command_args}
|
|
|
|
eend $?
|
|
}
|