blob: d578a2c0c5ba8529f5f43232bbb8cd9e1648a7df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: %%PORTNAME%%
# REQUIRE: NETWORKING SERVERS
# KEYWORD: shutdown
#
# Add these following line to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# %%PORTNAME%%_enable (bool): Set it to YES to enable keycloak on startup.
# Default: NO
# %%PORTNAME%%_host_config (string): Choose the host config if running in domain mode (host-master, host-slave).
# Default: host-master
# %%PORTNAME%%_mode (string): Choose the desired operating mode (standalone, standalone-ha, domain).
# Default: standalone
# %%PORTNAME%%_user (string): User account to run with.
# Default: www
# %%PORTNAME%%_flags (string): Additional flags for the startup script.
#
. /etc/rc.subr
name=%%PORTNAME%%
rcvar=%%PORTNAME%%_enable
desc="Identity and access management solution"
load_rc_config $name
: ${%%PORTNAME%%_enable:=NO}
: ${%%PORTNAME%%_host_config:="host-master"}
: ${%%PORTNAME%%_mode:=standalone}
: ${%%PORTNAME%%_user:=%%USER%%}
: ${%%PORTNAME%%_group:=%%GROUP%%}
: ${%%PORTNAME%%_flags:=""}
pidfile=%%RUN_DIR%%/%%PORTNAME%%.pid
command=/usr/sbin/daemon
command_args="-u ${%%PORTNAME%%_user} -o %%LOG_DIR%%/%%PORTNAME%%.out -t %%PORTNAME%% -R 60 -P ${pidfile}"
start_cmd="%%PORTNAME%%_start"
stop_cmd="%%PORTNAME%%_stop"
%%PORTNAME%%_start()
{
local %%PORTNAME%%_startscript
if [ ${%%PORTNAME%%_mode} = "domain" ]; then
%%PORTNAME%%_flags="--host-config=${%%PORTNAME%%_host_config} ${%%PORTNAME%%_flags}"
%%PORTNAME%%_startscript=domain.sh
elif [ ${%%PORTNAME%%_mode} = "standalone-ha" ]; then
%%PORTNAME%%_flags="--server-config=standalone-ha.xml ${%%PORTNAME%%_flags}"
%%PORTNAME%%_startscript=standalone.sh
else
%%PORTNAME%%_startscript=standalone.sh
fi
if [ ! -d "%%LOG_DIR%%" ]; then
install -d -o ${%%PORTNAME%%_user} %%LOG_DIR%%
fi
if [ ! -d "%%RUN_DIR%%" ]; then
install -d -o ${%%PORTNAME%%_user} %%RUN_DIR%%
fi
chown -R ${%%PORTNAME%%_user} %%LOG_DIR%%
chown -R ${%%PORTNAME%%_user} %%JAVASHAREDIR%%/%%PORTNAME%%/domain
chown -R ${%%PORTNAME%%_user} %%JAVASHAREDIR%%/%%PORTNAME%%/standalone
echo "Starting %%PORTNAME%%."
${command} ${command_args} \
%%JAVASHAREDIR%%/%%PORTNAME%%/bin/${%%PORTNAME%%_startscript} \
${%%PORTNAME%%_flags}
}
%%PORTNAME%%_stop()
{
local pid_daemon
local pid_child
echo "Stopping %%PORTNAME%%."
pid_daemon=$(check_pidfile ${pidfile} ${command})
if [ ! -z "${pid_daemon}" ]; then
kill -TERM ${pid_daemon}
fi
pid_child=$(pgrep -U ${%%PORTNAME%%_user} -f %%JAVASHAREDIR%%/%%PORTNAME%%/jboss-modules.jar)
if [ ! -z "${pid_child}" ]; then
kill -TERM ${pid_child}
fi
wait_for_pids ${pid_daemon} ${pid_child}
}
run_rc_command "$1"
|