blob: a95cc6c3a3825901b8c57461982466eb112e22dd (
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
#!/bin/sh
# PROVIDE: seafile
# REQUIRE: LOGIN cleanvar mysql
# KEYWORD: shutdown
#
#
# Add the following lines to /etc/rc.conf to enable seafile:
#
# seafile_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable seafile.
# seafile_user (str): User to run seafile as
# Default to "%%USERS%%" created by the port
# seafile_group (str): Group to run seafile as
# Default to "%%GROUPS%%" created by the port
# seafile_path (str): Set to "" by default will use the path
# %%PREFIX%%/%%SEAFILE_SERVER%%.
# Set it to a different path.
# seafile_ccnet (str): Set to "" by default will use the path
# %%PREFIX%%/%%HAIWENDIR%%/ccnet.
# Set it to a different path.
# seafile_conf (str): Set to "" by default will use the path
# %%PREFIX%%/%%HAIWENDIR%%/conf.
# Set it to a different path.
# seafile_datadir (str): Set to "" by default will use the path
# in file %%PREFIX%%/%%HAIWENDIR%%/ccnet/seafile.ini.
# Set it to a different path.
# seafile_logdir (str): Set to "" by default will use the path
# %%PREFIX%%/%%HAIWENDIR%%/logs
# Set it to a different path.
# seafile_loglevel (str): Set to "info" by default.
# Possible values are debug, warning, info.
. /etc/rc.subr
name="seafile"
rcvar="seafile_enable"
load_rc_config $name
start_cmd="seafile_start"
restart_cmd="seafile_restart"
stop_cmd="seafile_stop"
: ${seafile_enable="NO"}
: ${seafile_user:="%%USERS%%"}
: ${seafile_group:="%%GROUPS%%"}
: ${seafile_path:="%%PREFIX%%/%%SEAFILE_SERVER%%"}
: ${seafile_ccnet:="%%PREFIX%%/%%HAIWENDIR%%/ccnet"}
: ${seafile_conf:="%%PREFIX%%/%%HAIWENDIR%%/conf"}
: ${seafile_datadir:="%%PREFIX%%/%%HAIWENDIR%%/seafile-data"}
: ${seafile_logdir:="%%PREFIX%%/%%HAIWENDIR%%/logs"}
: ${seafile_loglevel:="info"}
command="%%PREFIX%%/%%SEAFILE_SERVER%%/seafile/bin/seafile-controller"
command_args="-c \"${seafile_ccnet}\" -d \"${seafile_datadir}\" -F \"${seafile_conf}\" -l \"${seafile_logdir}\" -g \"${seafile_loglevel}\" -G \"${seafile_loglevel}\""
required_dirs="${seafile_ccnet} ${seafile_conf} ${seafile_datadir}"
test_config() {
if ! su -m ${seafile_user} -c "${command} -t ${command_args}" ; then
exit 1;
fi
}
check_component_running() {
name=$1
cmd=$2
if pid=$(pgrep -f "$cmd" 2>/dev/null); then
echo "{$name} is running, pid $pid. You can stop it by: "
echo
echo " kill $pid"
echo
echo "Stop it and try again."
echo
exit
fi
}
validate_already_running() {
if pid=$(pgrep -f "seafile-controller -c ${seafile_ccnet}" 2>/dev/null); then
echo "Seafile controller is already running, pid $pid"
echo
exit 1;
fi
check_component_running "ccnet-server" "ccnet-server -c ${seafile_ccnet}"
check_component_running "seaf-server" "seaf-server -c ${seafile_ccnet}"
check_component_running "fileserver" "fileserver -c ${seafile_ccnet}"
check_component_running "seafdav" "wsgidav.server.run_server"
}
prepare_env() {
export PATH=${seafile_path}/seafile/bin:$PATH
export LD_LIBRARY_PATH=${seafile_path}/seafile/lib/:${seafile_path}/seafile/lib64:${LD_LIBRARY_PATH}
export CCNET_CONF_DIR=${seafile_ccnet}
export SEAFILE_CONF_DIR=${seafile_datadir}
export SEAFILE_CENTRAL_CONF_DIR=${seafile_conf}
export PYTHON=%%PREFIX%%/bin/%%PYTHON%%
export PYTHONPATH=${seafile_path}/seafile/lib/%%PYTHON%%/site-packages:${seafile_path}/seafile/lib64/%%PYTHON%%/site-packages:${seafile_path}/seahub/thirdpart:$PYTHONPATH
export SEAFILE_RPC_PIPE_PATH=${seafile_path}/runtime
}
seafile_start() {
check_required_before;
validate_already_running;
prepare_env;
# test_config broke in 8.0.x, commenting until this is fixed.
# https://forum.seafile.com/t/seafile-controller-t-functionality-broken-on-8-x/13738
# test_config;
echo "Starting seafile server, please wait ..."
su -m "${seafile_user}" -c "mkdir -p $seafile_logdir"
su -m "${seafile_user}" -c "$command $command_args"
sleep 3
# check if seafile server started successfully
if ! pgrep -f "seafile-controller -c ${seafile_ccnet}" 2>/dev/null 1>&2; then
echo "Failed to start seafile server"
exit 1;
fi
echo "Seafile server started"
echo
}
seafile_stop() {
if ! pgrep -f "seafile-controller -c ${seafile_ccnet}" 2>/dev/null 1>&2; then
echo "Seafile is not running"
return 1;
fi
echo "Stopping ${name}."
pkill -SIGTERM -f "seafile-controller -c ${seafile_ccnet}"
pkill -f "ccnet-server -c ${seafile_ccnet}"
pkill -f "seaf-server -c ${seafile_ccnet}"
pkill -f "fileserver -c ${seafile_ccnet}"
pkill -f "soffice.*--invisible --nocrashreport"
pkill -f "wsgidav.server.run_server"
return 0
}
seafile_restart() {
seafile_stop;
sleep 2
seafile_start;
}
run_rc_command "$1"
|