seafile-server: Update to 7.1.2, revamp package

* Package scripts that are shipped by upstream in their binary download

  * Includes setup scripts (setup-seafile.sh to use SQLite,
    setup-seafile-mysql.{sh,py} to use MySQL) and control scripts
    (seafile.sh, seahub.sh)

  * Does not include seafile-admin, which is not shipped in upstream's
    binary download. Combined with the fact that it hasn't been updated
    to Python 3 suggests the script has been abandoned.

* Replace previous init scripts with a simplified script

  * Previous init scripts (seafile.init, seahub.init) were modified from
    older versions of seafile.sh and seahub.sh, but they haven't kept up
    with changes to upstream's scripts

  * New init script (seafile-server.init) start/stops both Seafile and
    Seahub (there is no need to control them separately) by calling
    upstream's control scripts

* Replace previous package config file with new config file

  * Options in previous config file (seafile.conf) were mainly for using
    Seahub in FastCGI mode. FastCGI was deprecated in Django 1.7 and
    removed in 1.9; upstream's control script will only start Seahub
    using Gunicorn. (Options for Gunicorn including port number can be
    changed by editing /etc/seafile/conf/gunicorn.conf.py.)

  * New config file (seafile-server.config) has one option that controls
    where the Seafile/Seahub data directories are stored

* Patch scripts/binaries to use standard, system-wide directory
  locations

  * Script files (wrappers for binaries) in /usr/bin
  * Binaries (not meant to be run directly by the user) in /usr/libexec
  * Config files in /etc/seafile
  * Pid/socket files in /var/run/seafile
  * Logs in /var/log/seafile

* Include a new script to create the first admin account

  * With upstream's original scripts, the user is required to
    interactively create the first admin account when Seahub is started
    for the first time

  * The user will now use the new script (create-seafile-admin.sh) to
    create the first admin account after setup (using setup-seafile.sh
    or setup-seafile-mysql.sh) and before starting Seafile/Seahub

  * seahub.sh is patched to only check if there is at least one admin
    account and exit with an error if there is no admin account

* Remove build config options and add seafile-server-fuse package

  * The console option controls whether the console window is shown when
    Seafile server is run on Windows. It has no use on Linux.

  * The fuse option controls whether seaf-fuse is built. (seaf-fuse is a
    FUSE implementation that allows the Seafile database/file system to
    be mounted to a local directory.) seaf-fuse is now always built and
    is available in a separate package (seafile-server-fuse).

* Add myself as a maintainer

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
This commit is contained in:
Jeffery To
2020-03-07 06:59:29 +08:00
parent 1d275a8f27
commit cbfd166b15
42 changed files with 1895 additions and 865 deletions
@@ -0,0 +1,10 @@
#!/bin/sh
TOPDIR=/usr/share/seafile
INSTALLPATH=$TOPDIR/seafile-server
seafile start || exit 1
seahub python-env python3 "$INSTALLPATH/check_init_admin.py"
seafile stop
@@ -0,0 +1,11 @@
config seafile-server
#
# Directory that holds:
#
# * Seafile data directory (seafile-data)
# * Seahub data directory (seahub-data)
# * Seahub database (seahub.db), if using SQLite
#
# Default: /usr/share/seafile
#
option data_dir /usr/share/seafile
@@ -0,0 +1,74 @@
#!/bin/sh /etc/rc.common
START=99
STOP=01
EXTRA_COMMANDS="generate_uci_conf"
TOPDIR=/usr/share/seafile
INSTALLPATH=$TOPDIR/seafile-server
uci_conf=/var/run/seafile/uci.conf
default_data_dir=$TOPDIR
seafile_server_latest_symlink=$TOPDIR/seafile-server-latest
seafile_data_dir_symlink=$TOPDIR/seafile-data
seahub_avatars_symlink=$INSTALLPATH/seahub/media/avatars
seahub_custom_media_symlink=$INSTALLPATH/seahub/media/custom
read_uci_section() {
local cfg="$1"
local data_dir
config_get data_dir "$cfg" data_dir "$default_data_dir"
uci_data_dir="$data_dir"
}
generate_uci_conf() {
local uci_data_dir="$default_data_dir"
config_load seafile-server
config_foreach read_uci_section seafile-server
mkdir -p "$uci_data_dir"
mkdir -p "${uci_conf%/*}"
cat <<- EOF > "$uci_conf"
export SEAFILE_UCI_CONF_DIR=/etc/seafile
export SEAFILE_UCI_DATA_DIR="$uci_data_dir"
export SEAFILE_UCI_LOG_DIR=/var/log/seafile
export SEAFILE_UCI_PID_DIR=/var/run/seafile
export SEAFILE_UCI_SOCKET_DIR=/var/run/seafile
EOF
[ ! -L "$seafile_server_latest_symlink" ] || rm -f "$seafile_server_latest_symlink"
[ ! -L "$seafile_data_dir_symlink" ] || rm -f "$seafile_data_dir_symlink"
[ ! -L "$seahub_avatars_symlink" ] || \
[ "$(readlink -f "$seahub_avatars_symlink")" = "$uci_data_dir/seahub-data/avatars" ] || \
ln -snf "$uci_data_dir/seahub-data/avatars" "$seahub_avatars_symlink"
[ ! -L "$seahub_custom_media_symlink" ] || \
[ "$(readlink -f "$seahub_custom_media_symlink")" = "$uci_data_dir/seahub-data/custom" ] || \
ln -snf "$uci_data_dir/seahub-data/custom" "$seahub_custom_media_symlink"
}
start() {
seafile start || return
if ! seahub start; then
seafile stop
return 1
fi
}
stop() {
seahub stop
seahub_ret=$?
seafile stop
seafile_ret=$?
[ "$seahub_ret" -eq 0 ] && [ "$seafile_ret" -eq 0 ]
}
restart() {
stop
sleep 2
start
}
@@ -0,0 +1 @@
/etc/seafile/
-12
View File
@@ -1,12 +0,0 @@
# Start Seahub in fastcgi mode - 1 = enable, 0 = disable
SEAHUB_FASTCGI=0
# Listen on the port specified below (defaults to 8000)
SEAHUB_PORT=8000
# Method of serving requests (fastcgi mode only) - threaded or prefork
# Using threaded mode is recommended as it consumes less resources
SEAHUB_METHOD=threaded
# The maximum number of worker processes/threads (fastcgi mode only)
# General formula: (2 x $num_cores) + 1
# To set the number of workers in WSGI mode (which is the default)
# please edit /usr/share/seafile/seafile-server/runtime/seahub.conf
SEAHUB_WORKERS=3
-157
View File
@@ -1,157 +0,0 @@
#!/bin/bash /etc/rc.common
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"
TOPDIR=/usr/share/seafile
default_ccnet_conf_dir=${TOPDIR}/ccnet
central_config_dir=${TOPDIR}/conf
seaf_controller=/usr/bin/seafile-controller
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
}
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
}
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
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
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
}
function restart_seafile_server () {
stop_seafile_server
start_seafile_server
}
function start() {
start_seafile_server
}
function stop() {
stop_seafile_server
}
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
}
-226
View File
@@ -1,226 +0,0 @@
#!/bin/bash /etc/rc.common
START=99
APP=seahub
EXTRA_HELP=" clearsessions Clears expired sessions from database"
EXTRA_COMMANDS="clearsessions"
SEAHUB_FASTCGI=0
SEAHUB_PORT=8000
SEAHUB_METHOD=threaded
SEAHUB_WORKERS=3
[ -f /etc/config/seafile ] && \
. /etc/config/seafile
INSTALLPATH=/usr/share/seafile/seafile-server
TOPDIR=$(dirname "${INSTALLPATH}")
default_ccnet_conf_dir=${TOPDIR}/ccnet
central_config_dir=${TOPDIR}/conf
manage_py=${INSTALLPATH}/seahub/manage.py
gunicorn_conf=${INSTALLPATH}/runtime/seahub.conf
pidfile=/var/run/seafile/seahub.pid
errorlog=${INSTALLPATH}/runtime/error.log
accesslog=${INSTALLPATH}/runtime/access.log
gunicorn_exe=/usr/bin/gunicorn
function check_python_executable() {
if [[ "$PYTHON" != "" && -x $PYTHON ]]; then
return 0
fi
if which python2.7 2>/dev/null 1>&2; then
PYTHON=python2.7
elif which python27 2>/dev/null 1>&2; then
PYTHON=python27
else
echo
echo "Can't find a python executable of version 2.7 or above in PATH"
echo "Install python 2.7+ before continue."
echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it"
echo
exit 1
fi
}
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
}
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 validate_seahub_running() {
if pid=$(pgrep -f "${manage_py}" 2>/dev/null); then
return 1
elif pid=$(pgrep -f "seahub.wsgi:application" 2>/dev/null); then
return 1
fi
}
function validate_port() {
if ! [[ ${SEAHUB_PORT} =~ ^[1-9][0-9]{1,4}$ ]] ; then
printf "\033[033m${SEAHUB_PORT}\033[m is not a valid port number\n"
exit 1
fi
}
function warning_if_seafile_not_running() {
if ! pgrep -f "seafile-controller -F ${central_config_dir}" 2>/dev/null 1>&2; then
echo
echo "Error: seafile-controller not running. Have you run \"/etc/init.d/seafile start\"?"
echo
exit 1
fi
}
function prepare_seahub_log_dir() {
logdir="${TOPDIR}/logs"
if ! [[ -d "${logsdir}" ]]; then
if ! mkdir -p "${logdir}"; then
echo "Error: failed to create log dir \"${logdir}\""
exit 1
fi
fi
export SEAHUB_LOG_DIR="${logdir}"
}
function before_start() {
prepare_env
warning_if_seafile_not_running
if ! validate_seahub_running; then
echo "Seahub is already running."
exit 1
fi
prepare_seahub_log_dir
validate_port
}
function start_seahub() {
before_start
echo "Starting seahub at port ${SEAHUB_PORT} ..."
check_init_admin
$PYTHON $gunicorn_exe seahub.wsgi:application -c "${gunicorn_conf}" -b "0.0.0.0:${SEAHUB_PORT}" --preload
# Ensure seahub is started successfully
retry=1
while ! validate_seahub_running && [[ ! -f "${pidfile}" ]] && [[ $retry -lt 120 ]]; do sleep 1; ((retry++)); done
if ! validate_seahub_running && [[ -f "${pidfile}" ]]; then
echo
echo "Seahub is started"
echo
else
printf "\033[33mError: Seahub failed to start.\033[m\n"
exit 1
fi
}
function start_seahub_fastcgi() {
before_start
# Returns 127.0.0.1 if SEAFILE_FASTCGI_HOST is unset or hasn't got any value,
# otherwise returns value of SEAFILE_FASTCGI_HOST environment variable
address=`(test -z "$SEAFILE_FASTCGI_HOST" && echo "127.0.0.1") || echo $SEAFILE_FASTCGI_HOST`
echo "Starting seahub (fastcgi) at ${address}:${SEAHUB_PORT} ..."
check_init_admin
$PYTHON "${manage_py}" runfcgi host=${address} port=${SEAHUB_PORT} pidfile=${pidfile} \
outlog=${accesslog} errlog=${errorlog} maxchildren=${SEAHUB_WORKERS} method=${SEAHUB_METHOD}
# Ensure seahub is started successfully
retry=1
while ! validate_seahub_running && [[ ! -f "${pidfile}" ]] && [[ $retry -lt 120 ]]; do sleep 1; ((retry++)); done
if ! validate_seahub_running && [[ -f "${pidfile}" ]]; then
echo
echo "Seahub is started"
echo
else
printf "\033[33mError: Seahub failed to start.\033[m\n"
exit 1
fi
}
function prepare_env() {
check_python_executable
validate_ccnet_conf_dir
read_seafile_data_dir
export CCNET_CONF_DIR=${default_ccnet_conf_dir}
export SEAFILE_CONF_DIR=${seafile_data_dir}
export SEAFILE_CENTRAL_CONF_DIR=${central_config_dir}
export PYTHONPATH="${INSTALLPATH}/seahub:${INSTALLPATH}/seahub/thirdpart:${PYTHONPATH}"
}
function clear_sessions() {
prepare_env
echo "Start clear expired session records ..."
$PYTHON "${manage_py}" clearsessions
echo
echo "Done"
echo
}
function stop_seahub() {
if [[ -f ${pidfile} ]]; then
pid=$(cat "${pidfile}")
echo "Stopping seahub ..."
kill ${pid}
rm -f ${pidfile}
retry=1
while ! validate_seahub_running && [ $retry -lt 60 ]; do sleep 1; ((retry++)); done
if ! validate_seahub_running; then
echo "Error: seahub cannot be stopped. Please try stopping it manually by running \"kill $(echo "$pid" | tr '\n' ' ')\"."
echo "To force killing the processes, use \"kill -9 $(echo "$pid" | tr '\n' ' ')\"."
fi
else
echo "Seahub is not running"
fi
}
function check_init_admin() {
check_init_admin_script=${INSTALLPATH}/check_init_admin.py
if ! $PYTHON $check_init_admin_script; then
exit 1
fi
}
function start() {
if [ "$SEAHUB_FASTCGI" == "1" ]; then
start_seahub_fastcgi
else
start_seahub
fi
}
function stop() {
stop_seahub
}
function restart() {
stop
start
}
function clearsessions() {
clear_sessions
}