Lines 4-10
Link Here
|
4 |
# |
4 |
# |
5 |
|
5 |
|
6 |
# PROVIDE: seafile |
6 |
# PROVIDE: seafile |
7 |
# REQUIRE: LOGIN cleanvar |
7 |
# REQUIRE: LOGIN cleanvar mysql |
8 |
# KEYWORD: shutdown |
8 |
# KEYWORD: shutdown |
9 |
# |
9 |
# |
10 |
|
10 |
|
Lines 13-59
Link Here
|
13 |
# |
13 |
# |
14 |
# seafile_enable (bool): Set to "NO" by default. |
14 |
# seafile_enable (bool): Set to "NO" by default. |
15 |
# Set it to "YES" to enable seafile. |
15 |
# Set it to "YES" to enable seafile. |
|
|
16 |
# seafile_user (str): User to run seafile as |
17 |
# Default to "%%SEAFILE_USERNAME%%" created by the port |
18 |
# seafile_group (str): Group to run seafile as |
19 |
# Default to "%%SEAFILE_GROUPNAME%%" created by the port |
16 |
# seafile_path (str): Set to "" by default will use the path |
20 |
# seafile_path (str): Set to "" by default will use the path |
17 |
# /usr/local/www/haiwen/seafile-server. |
21 |
# %%PREFIX%%/%%SEAFILE_SERVER%%. |
18 |
# Set it to a different path. |
22 |
# Set it to a different path. |
|
|
23 |
# seafile_ccnet (str): Set to "" by default will use the path |
24 |
# %%PREFIX%%/%%HAIWENDIR%%/ccnet. |
25 |
# Set it to a different path. |
26 |
# seafile_conf (str): Set to "" by default will use the path |
27 |
# %%PREFIX%%/%%HAIWENDIR%%/conf. |
28 |
# Set it to a different path. |
29 |
# seafile_datadir (str): Set to "" by default will use the path |
30 |
# in file %%PREFIX%%/%%HAIWENDIR%%/ccnet/seafile.ini. |
31 |
# Set it to a different path. |
32 |
# seafile_logdir (str): Set to "" by default will use the path |
33 |
# %%PREFIX%%/%%HAIWENDIR%%/logs |
34 |
# Set it to a different path. |
35 |
# seafile_ccnet_debug (str): Set to "info" by default. |
36 |
# Possible values are debug, warning, info. |
37 |
# seafile_seafile_debug (str): Set to "info" by default. |
38 |
# Possible values are debug, warning, info. |
19 |
|
39 |
|
20 |
. /etc/rc.subr |
40 |
. /etc/rc.subr |
21 |
|
41 |
|
22 |
name="seafile" |
42 |
name="seafile" |
23 |
rcvar=seafile_enable |
43 |
rcvar="seafile_enable" |
24 |
|
44 |
|
25 |
load_rc_config $name |
45 |
load_rc_config $name |
26 |
|
46 |
|
27 |
start_cmd="${name}_start" |
47 |
start_cmd="seafile_start" |
28 |
restart_cmd="${name}_restart" |
48 |
restart_cmd="seafile_restart" |
29 |
stop_cmd="${name}_stop" |
49 |
stop_cmd="seafile_stop" |
30 |
|
50 |
|
31 |
: ${seafile_path:=%%PREFIX%%/www/haiwen/seafile-server} |
51 |
: ${seafile_enable="NO"} |
|
|
52 |
: ${seafile_user:=%%SEAFILE_USERNAME%%} |
53 |
: ${seafile_group:=%%SEAFILE_GROUPNAME%%} |
54 |
: ${seafile_path:=%%PREFIX%%/%%SEAFILE_SERVER%%} |
55 |
: ${seafile_ccnet:=%%PREFIX%%/%%HAIWENDIR%%/ccnet} |
56 |
: ${seafile_conf:=%%PREFIX%%/%%HAIWENDIR%%/conf} |
57 |
: ${seafile_datadir:=`cat ${seafile_ccnet}/seafile.ini`} |
58 |
: ${seafile_logdir:=%%PREFIX%%/%%HAIWENDIR%%/logs} |
59 |
: ${seafile_ccnet_debug:=info} |
60 |
: ${seafile_seafile_debug:=info} |
32 |
|
61 |
|
33 |
command="$seafile_path/seafile.sh" |
62 |
command="%%PREFIX%%/%%SEAFILE_SERVER%%/seafile/bin/seafile-controller" |
|
|
63 |
command_args="-c \"${seafile_ccnet}\" -d \"${seafile_datadir}\" -F \"${seafile_conf}\" -L \"${seafile_logdir}\" -g \"${seafile_ccnet_debug}\" -G \"${seafile_seafile_debug}\"" |
34 |
|
64 |
|
35 |
seafile_start() |
65 |
required_dirs="${seafile_ccnet} ${seafile_conf} ${seafile_datadir}" |
36 |
{ |
66 |
required_files="${seafile_ccnet}/seafile.ini" |
37 |
if checkyesno ${name}_enable; then |
67 |
|
38 |
start_script="${seafile_path}/seafile.sh" |
68 |
test_config() { |
39 |
echo "Starting seafile service" |
69 |
if ! su -m ${seafile_user} -c "${command} -t ${command_args}" ; then |
40 |
$command start |
70 |
exit 1; |
41 |
else |
|
|
42 |
return 0 |
43 |
fi |
71 |
fi |
44 |
} |
72 |
} |
45 |
|
73 |
|
46 |
seafile_stop() |
74 |
check_component_running() { |
47 |
{ |
75 |
name=$1 |
48 |
echo "Stoping seafile service" |
76 |
cmd=$2 |
49 |
$command stop |
77 |
if pid=$(pgrep -f "$cmd" 2>/dev/null); then |
|
|
78 |
echo "{$name} is running, pid $pid. You can stop it by: " |
79 |
echo |
80 |
echo " kill $pid" |
81 |
echo |
82 |
echo "Stop it and try again." |
83 |
echo |
84 |
exit |
85 |
fi |
50 |
} |
86 |
} |
51 |
|
87 |
|
52 |
seafile_restart() |
88 |
validate_already_running() { |
53 |
{ |
89 |
if pid=$(pgrep -f "seafile-controller -c ${seafile_ccnet}" 2>/dev/null); then |
54 |
echo "Restart seafile service" |
90 |
echo "Seafile controller is already running, pid $pid" |
55 |
$command restart |
91 |
echo |
|
|
92 |
exit 1; |
93 |
fi |
94 |
|
95 |
check_component_running "ccnet-server" "ccnet-server -c ${seafile_ccnet}" |
96 |
check_component_running "seaf-server" "seaf-server -c ${seafile_ccnet}" |
97 |
check_component_running "fileserver" "fileserver -c ${seafile_ccnet}" |
98 |
check_component_running "seafdav" "wsgidav.server.run_server" |
56 |
} |
99 |
} |
57 |
|
100 |
|
58 |
load_rc_config $name |
101 |
prepare_env() { |
|
|
102 |
export PATH=${seafile_path}/seafile/bin:$PATH |
103 |
export LD_LIBRARY_PATH=${seafile_path}/seafile/lib/:${seafile_path}/seafile/lib64:${LD_LIBRARY_PATH} |
104 |
} |
105 |
|
106 |
seafile_start() { |
107 |
check_required_before; |
108 |
validate_already_running; |
109 |
test_config; |
110 |
|
111 |
echo "Starting seafile server, please wait ..." |
112 |
|
113 |
su -m "${seafile_user}" -c "mkdir -p $seafile_logdir" |
114 |
su -m "${seafile_user}" -c "$command $command_args" |
115 |
|
116 |
sleep 3 |
117 |
|
118 |
# check if seafile server started successfully |
119 |
if ! pgrep -f "seafile-controller -c ${seafile_ccnet}" 2>/dev/null 1>&2; then |
120 |
echo "Failed to start seafile server" |
121 |
exit 1; |
122 |
fi |
123 |
|
124 |
echo "Seafile server started" |
125 |
echo |
126 |
} |
127 |
|
128 |
seafile_stop() { |
129 |
if ! pgrep -f "seafile-controller -c ${seafile_ccnet}" 2>/dev/null 1>&2; then |
130 |
echo "Seafile is not running" |
131 |
return 1; |
132 |
fi |
133 |
|
134 |
echo "Stopping ${name}." |
135 |
pkill -SIGTERM -f "seafile-controller -c ${seafile_ccnet}" |
136 |
pkill -f "ccnet-server -c ${seafile_ccnet}" |
137 |
pkill -f "seaf-server -c ${seafile_ccnet}" |
138 |
pkill -f "fileserver -c ${seafile_ccnet}" |
139 |
pkill -f "soffice.*--invisible --nocrashreport" |
140 |
pkill -f "wsgidav.server.run_server" |
141 |
return 0 |
142 |
} |
143 |
|
144 |
seafile_restart() { |
145 |
seafile_stop; |
146 |
sleep 2 |
147 |
seafile_start; |
148 |
} |
149 |
|
59 |
run_rc_command "$1" |
150 |
run_rc_command "$1" |