blob: b90b2995024e55ef15638b3adca3d9843820b1a8 (
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
75
76
77
78
79
80
81
82
83
84
85
|
#!/bin/sh
# PROVIDE: cells
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable Pydio Cells:
#
# cells_enable (bool): Set to "NO" by default.
# Set to "YES" to enable Pydio Cells.
# cells_user (str): Default to "pydio".
# cells_group (str): Default to "pydio".
# User and group to run Pydio Cells with.
# cells_flags (str): Additional flags to append to "cells start" command.
# Read `cells help start` for more information.
# cells_workingdir (str): Default to "/var/pydio/.config/pydio/cells".
# Application directory.
# cells_logdir (str): Default to "${cells_workingdir}/logs".
# Directory for application logs.
. /etc/rc.subr
name=cells
rcvar=cells_enable
desc="Pydio Cells"
load_rc_config cells
: ${cells_enable:=NO}
: ${cells_user:=pydio}
: ${cells_group:=pydio}
: ${cells_workingdir=/var/pydio/.config/pydio/cells}
: ${cells_logdir="${cells_workingdir}/logs"}
_envvars="CELLS_WORKING_DIR=${cells_workingdir} CELLS_LOG_DIR=${cells_logdir}"
_sucmd=/usr/bin/su
extra_commands=cli
pidfile=/var/run/${name}/${name}.pid
cli_precmd=cells_precmd
cli_cmd="cells_cli $@"
start_precmd=cells_precmd
stop_cmd=cells_stop
procname="%%PREFIX%%/bin/cells"
command=/usr/sbin/daemon
command_args="-p ${pidfile} -o ${cells_logdir}/cells.log env ${_envvars} ${procname} start ${cells_flags}"
cells_precmd()
{
# Create PID file directory
install -d -o ${cells_user} -g ${cells_group} -m 0755 "$(dirname ${pidfile})"
# Remove default flags, they're added in `command_args` manually
rc_flags=""
}
cells_cli()
{
shift 1
${_sucmd} -l ${cells_user} -c "exec env ${_envvars} ${procname} $*"
}
cells_stop()
{
# Copy-paste from rc.subr
if [ -z "${rc_pid}" ]; then
[ -n "${rc_fast}" ] && return 0
_run_rc_notrunning
return 1
fi
_children_pids=$(pgrep -P ${rc_pid})
echo "Stopping ${name}."
_run_rc_doit "kill -TERM ${rc_pid}" || return 1
# Stopping children is unreliable, so re-send TERM to them
# and wait for both the parent and the children
for _pid in ${_children_pids}; do
kill -TERM ${_pid}
done
wait_for_pids ${rc_pid} ${children_pids}
}
run_rc_command "$1"
|