Changeset View
Changeset View
Standalone View
Standalone View
net-mgmt/seafile/files/seafile.in
Context not available. | |||||
# | # | ||||
# PROVIDE: seafile | # PROVIDE: seafile | ||||
# REQUIRE: LOGIN cleanvar | # REQUIRE: LOGIN cleanvar mysql | ||||
# KEYWORD: shutdown | # KEYWORD: shutdown | ||||
# | # | ||||
Context not available. | |||||
# | # | ||||
# seafile_enable (bool): Set to "NO" by default. | # seafile_enable (bool): Set to "NO" by default. | ||||
# Set it to "YES" to enable seafile. | # Set it to "YES" to enable seafile. | ||||
# seafile_user (str): User to run seafile as | |||||
# Default to "%%SEAFILE_USERNAME%%" created by the port | |||||
# seafile_group (str): Group to run seafile as | |||||
# Default to "%%SEAFILE_GROUPNAME%%" created by the port | |||||
# seafile_path (str): Set to "" by default will use the path | # seafile_path (str): Set to "" by default will use the path | ||||
# /usr/local/www/haiwen/seafile-server. | # %%PREFIX%%/%%SEAFILE_SERVER%%. | ||||
# Set it to a different path. | # 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_ccnet_debug (str): Set to "info" by default. | |||||
# Possible values are debug, warning, info. | |||||
# seafile_seafile_debug (str): Set to "info" by default. | |||||
# Possible values are debug, warning, info. | |||||
. /etc/rc.subr | . /etc/rc.subr | ||||
name="seafile" | name="seafile" | ||||
rcvar=seafile_enable | rcvar="seafile_enable" | ||||
load_rc_config $name | load_rc_config $name | ||||
start_cmd="${name}_start" | start_cmd="seafile_start" | ||||
restart_cmd="${name}_restart" | restart_cmd="seafile_restart" | ||||
stop_cmd="${name}_stop" | stop_cmd="seafile_stop" | ||||
: ${seafile_path:=%%PREFIX%%/www/haiwen/seafile-server} | : ${seafile_enable="NO"} | ||||
: ${seafile_user:=%%SEAFILE_USERNAME%%} | |||||
: ${seafile_group:=%%SEAFILE_GROUPNAME%%} | |||||
: ${seafile_path:=%%PREFIX%%/%%SEAFILE_SERVER%%} | |||||
: ${seafile_ccnet:=%%PREFIX%%/%%HAIWENDIR%%/ccnet} | |||||
: ${seafile_conf:=%%PREFIX%%/%%HAIWENDIR%%/conf} | |||||
: ${seafile_datadir:=`cat ${seafile_ccnet}/seafile.ini`} | |||||
: ${seafile_logdir:=%%PREFIX%%/%%HAIWENDIR%%/logs} | |||||
: ${seafile_ccnet_debug:=info} | |||||
: ${seafile_seafile_debug:=info} | |||||
command="$seafile_path/seafile.sh" | command="%%PREFIX%%/%%SEAFILE_SERVER%%/seafile/bin/seafile-controller" | ||||
command_args="-c \"${seafile_ccnet}\" -d \"${seafile_datadir}\" -F \"${seafile_conf}\" -L \"${seafile_logdir}\" -g \"${seafile_ccnet_debug}\" -G \"${seafile_seafile_debug}\"" | |||||
seafile_start() | required_dirs="${seafile_ccnet} ${seafile_conf} ${seafile_datadir}" | ||||
{ | required_files="${seafile_ccnet}/seafile.ini" | ||||
if checkyesno ${name}_enable; then | |||||
start_script="${seafile_path}/seafile.sh" | test_config() { | ||||
echo "Starting seafile service" | if ! su -m ${seafile_user} -c "${command} -t ${command_args}" ; then | ||||
$command start | exit 1; | ||||
else | |||||
return 0 | |||||
fi | fi | ||||
} | } | ||||
seafile_stop() | check_component_running() { | ||||
{ | name=$1 | ||||
echo "Stoping seafile service" | cmd=$2 | ||||
$command stop | 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 | |||||
} | } | ||||
seafile_restart() | validate_already_running() { | ||||
{ | if pid=$(pgrep -f "seafile-controller -c ${seafile_ccnet}" 2>/dev/null); then | ||||
echo "Restart seafile service" | echo "Seafile controller is already running, pid $pid" | ||||
$command restart | 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" | |||||
} | } | ||||
load_rc_config $name | prepare_env() { | ||||
export PATH=${seafile_path}/seafile/bin:$PATH | |||||
export LD_LIBRARY_PATH=${seafile_path}/seafile/lib/:${seafile_path}/seafile/lib64:${LD_LIBRARY_PATH} | |||||
} | |||||
seafile_start() { | |||||
check_required_before; | |||||
validate_already_running; | |||||
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" | run_rc_command "$1" | ||||
Context not available. |