Created
August 8, 2018 01:49
-
-
Save tatsuyaueda/09286695eac2739d762e9df0f3894223 to your computer and use it in GitHub Desktop.
FreeBSD Keycloak Startup Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# PROVIDE: keycloak | |
# REQUIRE: LOGIN DAEMON NETWORKING | |
# KEYWORD: shutdown | |
# | |
# Add the following lines to /etc/rc.conf.local to enable the Keycloak: | |
# | |
# keycloak_enable="YES" | |
# keycloak_path="/root/keycloak-4.2.1.Final/bin/standalone.sh" | |
# keycloak_args="<keycloak options>" | |
# | |
. /etc/rc.subr | |
export PATH=$PATH:/usr/local/bin/ | |
name="keycloak" | |
rcvar=`set_rcvar` | |
load_rc_config ${name} | |
pidfile="/var/run/${name}.pid" | |
logfile="/var/log/${name}.log" | |
export LAUNCH_JBOSS_IN_BACKGROUND=true | |
export JBOSS_PIDFILE=${pidfile} | |
extra_commands="status" | |
start_cmd="${name}_start" | |
stop_cmd="${name}_stop" | |
status_cmd="${name}_status" | |
: ${keycloak_enable="NO"} | |
: ${keycloak_path=""} | |
: ${keycloak_args="-b=0.0.0.0"} | |
keycloak_start() { | |
if [ "x${keycloak_path}" == "x" ]; then | |
echo "keycloak_path is empty." | |
return 0 | |
fi | |
echo "Starting ${name}" | |
if keycloak_running; then | |
echo ": already running?" | |
else | |
${keycloak_path} ${keycloak_args} >>$logfile 2>&1 & | |
fi | |
} | |
keycloak_stop() { | |
if [ -e ${pidfile} ]; then | |
echo "Stopping ${name}" | |
kill `cat ${pidfile}`; | |
else | |
echo ${name} is not running? | |
fi | |
} | |
keycloak_status() { | |
if keycloak_running; then | |
echo "${name} is running." | |
else | |
echo "${name} is not running." | |
fi | |
} | |
keycloak_running() { | |
if [ -e ${pidfile} ]; then | |
return 0 | |
else | |
return 1 | |
fi | |
return 1 | |
} | |
run_rc_command $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment