1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 15:38:15 +00:00
This commit is contained in:
skywalker
2021-12-04 10:45:09 +08:00
parent 5a8ca8737f
commit 2aad273a3a
7 changed files with 218 additions and 22 deletions

View File

@@ -6,6 +6,8 @@ TOPDIR=$(dirname "${INSTALLPATH}")
default_ccnet_conf_dir=${TOPDIR}/ccnet
default_seafile_data_dir=${TOPDIR}/seafile-data
central_config_dir=${TOPDIR}/conf
pro_pylibs_dir=${INSTALLPATH}/pro/python
seafesdir=$pro_pylibs_dir/seafes
function check_python_executable() {
if [[ "$PYTHON" != "" && -x $PYTHON ]]; then
@@ -62,5 +64,13 @@ export SEAFILE_CENTRAL_CONF_DIR=${central_config_dir}
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3/site-packages:${INSTALLPATH}/seafile/lib64/python3/site-packages:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
export SEAFILE_RPC_PIPE_PATH=${INSTALLPATH}/runtime
if [[ -d ${INSTALLPATH}/pro ]]; then
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
export SEAFES_DIR=$seafesdir
export SEAFILE_RPC_PIPE_PATH=${INSTALLPATH}/runtime
fi
manage_py=${INSTALLPATH}/seahub/manage.py
exec "$PYTHON" "$manage_py" createsuperuser

View File

@@ -8,6 +8,7 @@ TOPDIR=$(dirname "${INSTALLPATH}")
default_ccnet_conf_dir=${TOPDIR}/ccnet
default_seafile_data_dir=${TOPDIR}/seafile-data
default_conf_dir=${TOPDIR}/conf
check_db_py=${INSTALLPATH}/check-db-type.py
seaf_gc=${INSTALLPATH}/seafile/bin/seafserv-gc
seaf_gc_opts=""
@@ -17,10 +18,38 @@ export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafil
script_name=$0
function usage () {
echo "usage : "
if [[ -d ${INSTALLPATH}/pro ]]; then
echo "$(basename ${script_name}) [--dry-run | -D] [--rm-deleted | -r] [--rm-fs | -R] [repo-id1] [repo-id2]"
else
echo "$(basename ${script_name}) [--dry-run | -D] [--rm-deleted | -r] [repo-id1] [repo-id2]"
fi
echo ""
}
function check_python_executable() {
if [[ "$PYTHON" != "" && -x $PYTHON ]]; then
return 0
fi
if which python3 2>/dev/null 1>&2; then
PYTHON=python3
elif !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then
echo
echo "The current version of python is not 3.x.x, please use Python 3.x.x ."
echo
exit 1
else
PYTHON="python"$(python --version | cut -b 8-10)
if !which $PYTHON 2>/dev/null 1>&2; then
echo
echo "Can't find a python executable of $PYTHON in PATH"
echo "Install $PYTHON before continue."
echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it"
echo
exit 1
fi
fi
}
function validate_seafile_data_dir () {
if [[ ! -d ${default_seafile_data_dir} ]]; then
@@ -58,7 +87,18 @@ function validate_already_running () {
}
function run_seaf_gc () {
if [[ -d ${INSTALLPATH}/pro ]]; then
seafile_conf=${default_conf_dir}/seafile.conf
db_type=$($PYTHON $check_db_py $seafile_conf)
if [ $db_type = "sqlite" ]; then
validate_already_running;
fi
else
validate_already_running;
fi
validate_seafile_data_dir;
echo "Starting seafserv-gc, please wait ..."
@@ -73,6 +113,8 @@ function run_seaf_gc () {
echo
}
check_python_executable;
if [ $# -gt 0 ];
then
for param in $@;

View File

@@ -19,6 +19,8 @@ default_ccnet_conf_dir=${TOPDIR}/ccnet
default_seafile_data_dir=${TOPDIR}/seafile-data
central_config_dir=${TOPDIR}/conf
seaf_controller="${INSTALLPATH}/seafile/bin/seafile-controller"
pro_pylibs_dir=${INSTALLPATH}/pro/python
seafesdir=$pro_pylibs_dir/seafes
export PATH=${INSTALLPATH}/seafile/bin:$PATH
export ORIG_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
@@ -48,6 +50,14 @@ function validate_running_user () {
fi
}
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3/site-packages:${INSTALLPATH}/seafile/lib64/python3/site-packages:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
if [[ -d ${INSTALLPATH}/pro ]]; then
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
export SEAFES_DIR=$seafesdir
fi
function validate_central_conf_dir () {
if [[ ! -d ${central_config_dir} ]]; then
echo "Error: there is no conf/ directory."
@@ -66,6 +76,12 @@ function validate_seafile_data_dir () {
fi
}
function test_config() {
if ! LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${seaf_controller} -t -c "${default_ccnet_conf_dir}" -d "${default_seafile_data_dir}" -F "${central_config_dir}" ; then
exit 1;
fi
}
function check_component_running() {
name=$1
cmd=$2
@@ -90,6 +106,14 @@ function validate_already_running () {
check_component_running "seaf-server" "seaf-server -c ${default_ccnet_conf_dir}"
check_component_running "fileserver" "fileserver -c ${default_ccnet_conf_dir}"
check_component_running "seafdav" "wsgidav.server.server_cli"
check_component_running "seafevents" "seafevents.main --config-file ${central_config_dir}"
}
function test_java {
if ! which java 2>/dev/null 1>&2; then
echo "java is not found on your machine. Please install it first."
exit 1;
fi
}
function start_seafile_server () {
@@ -98,13 +122,29 @@ function start_seafile_server () {
validate_seafile_data_dir;
validate_running_user;
if [[ -d ${INSTALLPATH}/pro ]]; then
test_config;
test_java;
fi
echo "Starting seafile server, please wait ..."
mkdir -p $TOPDIR/logs
if [[ -d ${INSTALLPATH}/pro ]]; then
if ! LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${seaf_controller} -c "${default_ccnet_conf_dir}" -d "${default_seafile_data_dir}" -F "${central_config_dir}"; then
controller_log="$default_seafile_data_dir/controller.log"
echo
echo "Failed to start seafile server. See $controller_log for more details."
echo
exit 1
fi
else
LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${seaf_controller} \
-c "${default_ccnet_conf_dir}" \
-d "${default_seafile_data_dir}" \
-F "${central_config_dir}"
fi
sleep 3
@@ -118,24 +158,32 @@ function start_seafile_server () {
echo
}
function kill_all () {
pkill -f "seaf-server -c ${default_ccnet_conf_dir}"
pkill -f "fileserver -c ${default_ccnet_conf_dir}"
pkill -f "seafevents.main"
pkill -f "convert_server.py"
pkill -f "soffice.*--invisible --nocrashreport"
pkill -f "wsgidav.server.server_cli"
}
function stop_seafile_server () {
if ! pgrep -f "seafile-controller -c ${default_ccnet_conf_dir}" 2>/dev/null 1>&2; then
echo "seafile server not running yet"
return 1;
kill_all
return 1
fi
echo "Stopping seafile server ..."
pkill -SIGTERM -f "seafile-controller -c ${default_ccnet_conf_dir}"
pkill -f "seaf-server -c ${default_ccnet_conf_dir}"
pkill -f "fileserver -c ${default_ccnet_conf_dir}"
pkill -f "soffice.*--invisible --nocrashreport"
pkill -f "wsgidav.server.server_cli"
kill_all
return 0
}
function restart_seafile_server () {
stop_seafile_server;
sleep 2
sleep 5
start_seafile_server;
}

View File

@@ -26,6 +26,8 @@ pidfile=${TOPDIR}/pids/seahub.pid
errorlog=${TOPDIR}/logs/gunicorn_error.log
accesslog=${TOPDIR}/logs/gunicorn_access.log
gunicorn_exe=${INSTALLPATH}/seahub/thirdpart/bin/gunicorn
pro_pylibs_dir=${INSTALLPATH}/pro/python
seafesdir=$pro_pylibs_dir/seafes
script_name=$0
function usage () {
@@ -144,12 +146,30 @@ function before_start() {
warning_if_seafile_not_running;
validate_seahub_running;
prepare_seahub_log_dir;
if [[ -d ${INSTALLPATH}/pro ]]; then
if [[ -z "$LANG" ]]; then
echo "LANG is not set in ENV, set to en_US.UTF-8"
export LANG='en_US.UTF-8'
fi
if [[ -z "$LC_ALL" ]]; then
echo "LC_ALL is not set in ENV, set to en_US.UTF-8"
export LC_ALL='en_US.UTF-8'
fi
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
export SEAFES_DIR=$seafesdir
fi
}
function start_seahub () {
before_start;
echo "Starting seahub at port ${port} ..."
check_init_admin;
export DJANGO_SETTINGS_MODULE=seahub.settings
$PYTHON $gunicorn_exe seahub.wsgi:application -c "${gunicorn_conf}" --preload
# Ensure seahub is started successfully
@@ -178,7 +198,7 @@ function start_seahub_fastcgi () {
# Ensure seahub is started successfully
sleep 5
if ! pgrep -f "${manage_py}" 1>/dev/null; then
if ! pgrep -f "${manage_py}" >/dev/null; then
printf "\033[33mError:Seahub failed to start.\033[m\n"
exit 1;
fi
@@ -248,6 +268,13 @@ function run_python_env() {
prepare_env;
if [[ -d ${INSTALLPATH}/pro ]]; then
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
export SEAFES_DIR=$seafesdir
fi
if which ipython 2>/dev/null; then
pyexec=ipython
else

View File

@@ -304,6 +304,7 @@ class EnvManager(object):
self.central_pids_dir = os.path.join(self.top_dir, 'pids')
self.central_logs_dir = os.path.join(self.top_dir, 'logs')
Utils.must_mkdir(self.central_config_dir)
self.is_pro = os.path.exists(os.path.join(self.install_path, 'pro'))
def check_pre_condiction(self):
def error_if_not_exists(path):
@@ -327,6 +328,7 @@ class EnvManager(object):
env = dict(os.environ)
env['CCNET_CONF_DIR'] = ccnet_config.ccnet_dir
env['SEAFILE_CONF_DIR'] = seafile_config.seafile_dir
env['SEAFES_DIR'] = os.path.join(self.install_path, 'pro', 'python', 'seafes')
self.setup_python_path(env)
return env
@@ -1216,6 +1218,31 @@ share_name = /
with open(self.seafdav_conf, 'w') as fp:
fp.write(text)
class ProfessionalConfigurator(AbstractConfigurator):
'''Seafile Pro related configuration'''
def __init__(self):
AbstractConfigurator.__init__(self)
self.pro_py = os.path.join(env_mgr.install_path, 'pro', 'pro.py')
self.pro_data_dir = os.path.join(env_mgr.top_dir, 'pro-data')
def ask_questions(self):
pass
def generate(self):
argv = [
Utils.get_python_executable(),
self.pro_py,
'setup',
'--mysql',
'--mysql_host=%s' % db_config.mysql_host,
'--mysql_port=%s' % db_config.mysql_port,
'--mysql_user=%s' % db_config.seafile_mysql_user,
'--mysql_password=%s' % db_config.seafile_mysql_password,
'--mysql_db=%s' % db_config.seahub_db_name,
]
if Utils.run_argv(argv, env=env_mgr.get_seahub_env()) != 0:
Utils.error('Failed to generate seafile pro configuration')
class GunicornConfigurator(AbstractConfigurator):
def __init__(self):
AbstractConfigurator.__init__(self)
@@ -1349,6 +1376,8 @@ seafdav_config = SeafDavConfigurator()
gunicorn_config = GunicornConfigurator()
seahub_config = SeahubConfigurator()
user_manuals_handler = UserManualHandler()
if env_mgr.is_pro:
pro_config = ProfessionalConfigurator()
# Would be created after AbstractDBConfigurator.ask_use_existing_db()
db_config = None
need_pause = True
@@ -1494,6 +1523,8 @@ def main():
ccnet_config.ask_questions()
seafile_config.ask_questions()
seahub_config.ask_questions()
if env_mgr.is_pro:
pro_config.ask_questions()
# pylint: disable=redefined-variable-type
if not db_config:
@@ -1513,6 +1544,8 @@ def main():
seafdav_config.generate()
gunicorn_config.generate()
seahub_config.generate()
if env_mgr.is_pro:
pro_config.generate()
ccnet_config.do_syncdb()
seafile_config.do_syncdb()

View File

@@ -49,8 +49,23 @@ function check_python () {
echo
}
function check_java () {
echo -n "Checking for java ..."
if ! which java 2>/dev/null 1>&2; then
echo -e "\nJava is not found. install it first.\n"
echo "On Debian/Ubuntu: apt-get install default-jre"
echo "On CentOS/RHEL: yum install jre"
err_and_quit;
fi
printf "Done.\n\n"
}
check_python;
if [[ -d ${INSTALLPATH}/pro ]]; then
check_java;
fi
export PYTHON=$PYTHON
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3/site-packages:${INSTALLPATH}/seafile/lib64/python3/site-packages:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH

View File

@@ -16,7 +16,11 @@ server_manual_http='https://download.seafile.com/published/seafile-manual/home.m
function welcome () {
echo "-----------------------------------------------------------------"
if [[ -d ${INSTALLPATH}/pro ]]; then
echo "This script will guide you to config and setup your seafile professional server."
else
echo "This script will guide you to config and setup your seafile server."
fi
echo -e "\nMake sure you have read seafile server manual at \n\n\t${server_manual_http}\n"
echo -e "Note: This script will guide your to setup seafile server using sqlite3,"
echo "which may have problems if your disk is on a NFS/CIFS/USB."
@@ -148,10 +152,26 @@ function check_sqlite3 () {
printf "Done.\n\n"
}
function check_java () {
echo -n "Checking for java ..."
if ! which java 2>/dev/null 1>&2; then
echo -e "\nJava is not found. install it first.\n"
echo "On Debian/Ubuntu: apt-get install default-jre"
echo "On CentOS/RHEL: yum install jre"
err_and_quit;
fi
printf "Done.\n\n"
}
function check_system_dependency () {
printf "Checking packages needed by seafile ...\n\n"
check_python;
check_sqlite3;
if [[ -d ${INSTALLPATH}/pro ]]; then
check_java;
fi
printf "Checking Done.\n\n"
}
@@ -489,7 +509,9 @@ fi
echo "Generating ccnet configuration in ${default_ccnet_conf_dir}..."
echo
gen_ccnet_conf;
echo
# -------------------------------------------
@@ -498,17 +520,11 @@ echo
echo "Generating seafile configuration in ${default_seafile_data_dir} ..."
echo
gen_seafile_conf;
echo
# -------------------------------------------
# Write seafile.ini
# -------------------------------------------
## use default seafile-data path: seafile_data_dir=${TOPDIR}/seafile-data
# echo "${seafile_data_dir}" > "${default_ccnet_conf_dir}/seafile.ini"
# -------------------------------------------
# Generate gunicorn.conf.py
# -------------------------------------------
@@ -708,6 +724,11 @@ chmod 0700 "$default_ccnet_conf_dir"
chmod 0700 "$default_seafile_data_dir"
chmod 0700 "$default_conf_dir"
if [[ -d ${INSTALLPATH}/pro ]]; then
pro_py=${INSTALLPATH}/pro/pro.py
$PYTHON ${pro_py} setup
fi
# -------------------------------------------
# copy user manuals to library template
# -------------------------------------------