mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 15:38:40 +01:00
seafile: import version 5.1.1 and its dependencies
Signed-off-by: Gergely Kiss <mail.gery@gmail.com>
This commit is contained in:
committed by
Etienne CHAMPETIER
parent
39e937fae7
commit
437621931a
@@ -1,57 +1,157 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#!/bin/bash /etc/rc.common
|
||||
|
||||
START=99
|
||||
START=98
|
||||
APP=seafile
|
||||
EXTRA_HELP=" setup Runs the setup script
|
||||
create_admin Creates the administrative login
|
||||
reset_admin Alias to create_admin"
|
||||
EXTRA_COMMANDS="setup create_admin reset_admin"
|
||||
|
||||
SEAHUB_FASTCGI=0
|
||||
TOPDIR=/usr/share/seafile
|
||||
default_ccnet_conf_dir=${TOPDIR}/ccnet
|
||||
central_config_dir=${TOPDIR}/conf
|
||||
seaf_controller=/usr/bin/seafile-controller
|
||||
|
||||
[ -f /etc/config/seafile ] && \
|
||||
. /etc/config/seafile
|
||||
function validate_ccnet_conf_dir () {
|
||||
if [[ ! -d ${default_ccnet_conf_dir} ]]; then
|
||||
echo "Error: there is no ccnet config directory."
|
||||
echo "Have you run \"/etc/init.d/seafile setup\"?"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
export PATH="/usr/share/seafile/seafile-server/seahub/thirdpart:${PATH}"
|
||||
export PYTHONPATH="/usr/share/seafile/seafile-server/seahub/thirdpart:${PYTHONPATH}"
|
||||
function validate_central_conf_dir () {
|
||||
if [[ ! -d ${central_config_dir} ]]; then
|
||||
echo "Error: there is no conf/ directory."
|
||||
echo "Have you run \"/etc/init.d/seafile setup\"?"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
if [ ! -d /var/run/seafile ]
|
||||
then
|
||||
mkdir /var/run/seafile
|
||||
chown seafile:seafile /var/run/seafile
|
||||
chmod o-rwx /var/run/seafile
|
||||
function read_seafile_data_dir () {
|
||||
seafile_ini=${default_ccnet_conf_dir}/seafile.ini
|
||||
if [[ ! -f ${seafile_ini} ]]; then
|
||||
echo "Error: ${seafile_ini} not found."
|
||||
exit 1
|
||||
fi
|
||||
seafile_data_dir=$(cat "${seafile_ini}")
|
||||
if [[ ! -d ${seafile_data_dir} ]]; then
|
||||
echo "Your seafile server data directory \"${seafile_data_dir}\" is invalid or doesn't exits."
|
||||
echo "Please check it first, or create this directory yourself."
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function test_config() {
|
||||
if ! ${seaf_controller} --test \
|
||||
-c "${default_ccnet_conf_dir}" \
|
||||
-d "${seafile_data_dir}" \
|
||||
-F "${central_config_dir}" ; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function check_component_running() {
|
||||
name=$1
|
||||
cmd=$2
|
||||
if pid=$(pgrep -f "$cmd" 2>/dev/null); then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function validate_already_running () {
|
||||
check_component_running "seafile-controller" "seafile-controller -F ${central_config_dir}" || return 1
|
||||
check_component_running "ccnet-server" "ccnet-server -F ${central_config_dir}" || return 1
|
||||
check_component_running "seaf-server" "seaf-server -F ${central_config_dir}" || return 1
|
||||
check_component_running "fileserver" "fileserver -F ${central_config_dir}" || return 1
|
||||
check_component_running "seafdav" "wsgidav.server.run_server" || return 1
|
||||
}
|
||||
|
||||
function start_seafile_server () {
|
||||
if ! validate_already_running; then
|
||||
if [[ "$name" == "seafile-controller" ]]; then
|
||||
echo "Seafile already running."
|
||||
else
|
||||
echo "Error: component [$name] is already running. Please try stopping it manually by running \"kill $pid\"."
|
||||
echo "To force killing the process, use \"kill -9 $pid\"."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
validate_central_conf_dir
|
||||
validate_ccnet_conf_dir
|
||||
read_seafile_data_dir
|
||||
test_config
|
||||
|
||||
echo "Starting seafile server, please wait ..."
|
||||
|
||||
${seaf_controller} \
|
||||
-F "${central_config_dir}" \
|
||||
-c "${default_ccnet_conf_dir}" \
|
||||
-d "${seafile_data_dir}"
|
||||
|
||||
sleep 3
|
||||
|
||||
# check if seafile server started successfully
|
||||
if ! pgrep -f "seafile-controller -F ${central_config_dir}" 2>/dev/null 1>&2; then
|
||||
echo "Failed to start seafile server"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ${SEAHUB_FASTCGI} -eq 1 ]; then
|
||||
cd "/usr/share/seafile" && \
|
||||
sudo PYTHONPATH="${PYTHONPATH}" -u seafile -E \
|
||||
"/usr/bin/seafile-admin" start --fastcgi
|
||||
echo "Seafile server started"
|
||||
echo
|
||||
}
|
||||
|
||||
function stop_seafile_server () {
|
||||
if ! pgrep -f "seafile-controller -F ${central_config_dir}" 2>/dev/null 1>&2; then
|
||||
echo "Seafile server not running"
|
||||
else
|
||||
cd "/usr/share/seafile" && \
|
||||
sudo PYTHONPATH="${PYTHONPATH}" -u seafile -E \
|
||||
"/usr/bin/seafile-admin" start
|
||||
echo "Stopping seafile server ..."
|
||||
pkill -SIGTERM -f "seafile-controller -F ${central_config_dir}"
|
||||
pkill -f "ccnet-server -F ${central_config_dir}"
|
||||
pkill -f "seaf-server -F ${central_config_dir}"
|
||||
pkill -f "fileserver -F ${central_config_dir}"
|
||||
pkill -f "soffice.*--invisible --nocrashreport"
|
||||
pkill -f "wsgidav.server.run_server"
|
||||
retry=1
|
||||
while ! validate_already_running && [ $retry -lt 60 ]; do sleep 1; ((retry++)); done
|
||||
if ! validate_already_running; then
|
||||
echo "Error: [$name] component is still running. Please try stopping it manually by running \"kill $pid\"."
|
||||
echo "To force killing the process, use \"kill -9 $pid\"."
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
cd "/usr/share/seafile" && \
|
||||
sudo PYTHONPATH="${PYTHONPATH}" -u seafile -E \
|
||||
"/usr/bin/seafile-admin" stop
|
||||
function restart_seafile_server () {
|
||||
stop_seafile_server
|
||||
start_seafile_server
|
||||
}
|
||||
|
||||
setup() {
|
||||
cd "/usr/share/seafile" && \
|
||||
sudo PYTHONPATH="${PYTHONPATH}" -u seafile -E \
|
||||
"/usr/bin/seafile-admin" setup
|
||||
function start() {
|
||||
start_seafile_server
|
||||
}
|
||||
|
||||
create_admin() {
|
||||
cd "/usr/share/seafile" && \
|
||||
sudo PYTHONPATH="${PYTHONPATH}" -u seafile -E \
|
||||
"/usr/bin/seafile-admin" create-admin
|
||||
function stop() {
|
||||
stop_seafile_server
|
||||
}
|
||||
|
||||
reset_admin() {
|
||||
function restart() {
|
||||
restart_seafile_server
|
||||
}
|
||||
|
||||
function setup() {
|
||||
cd "$TOPDIR" && \
|
||||
/usr/bin/seafile-admin setup
|
||||
}
|
||||
|
||||
function create_admin() {
|
||||
cd "$TOPDIR" && \
|
||||
/usr/bin/seafile-admin create-admin
|
||||
}
|
||||
|
||||
function reset_admin() {
|
||||
create_admin
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user