blob: 081380d2f183859862518aec5b5690204a313a0f (
plain) (
blame)
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
|
#!/bin/sh
#
# PROVIDE: kleened
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable and configure this service:
#
# kleened_enable (bool): Set to NO by default.
# Set it to YES to enable kleened.
# kleened_user (str): Set to "root" by default.
# kleened_config (str): Path to config file.
# Default: %%PREFIX%%/etc/kleened/config.yaml
# kleened_shutdown_timeout (int): Seconds to wait for graceful shutdown.
# Default: 60
. /etc/rc.subr
name=kleened
rcvar=kleened_enable
extra_commands="init dryinit"
# kleened_init: Initialize host configuration
# kleened_dryinit: Test host configuration without applying changes
required_files="${kleened_config}"
command="%%PREFIX%%/libexec/kleened/bin/kleened"
pidfile="/var/run/kleened.pid"
procname="$(/usr/bin/find %%PREFIX%%/libexec/kleened -name beam.smp)"
start_cmd="${command} daemon"
status_cmd="${command} ping"
stop_cmd="kleened_stop"
init_cmd="kleened_init"
dryinit_cmd="kleened_dryinit"
load_rc_config $name
: ${kleened_enable:=no}
: ${kleened_user:="root"}
: ${kleened_config:="%%ETCDIR%%/config.yaml"}
: ${kleened_shutdown_timeout:=60}
: ${kleened_env="LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 PATH=%%PREFIX%%/libexec/kleened/bin:${PATH}"}
kleened_stop()
{
echo "Stopping ${name}."
${command} stop
wait_for_pids ${pidfile} ${kleened_shutdown_timeout}
}
kleened_init()
{
echo "Initializing kleened host configuration..."
if %%PREFIX%%/libexec/kleened/bin/kleened eval "Kleened.Core.Config.initialize_host(%{dry_run: false})"; then
echo "Host initialization completed successfully"
else
echo "Host initialization failed"
return 1
fi
}
kleened_dryinit()
{
echo "Testing kleened host configuration..."
if %%PREFIX%%/libexec/kleened/bin/kleened eval "Kleened.Core.Config.initialize_host(%{dry_run: true})"; then
echo "Host configuration test completed successfully"
else
echo "Host configuration test failed"
return 1
fi
}
run_rc_command "$1"
|