1
0
mirror of https://github.com/haiwen/seafile-server.git synced 2025-07-18 01:01:08 +00:00
seafile-server/scripts/reset-admin.sh

67 lines
2.1 KiB
Bash
Raw Normal View History

2016-08-10 06:53:33 +00:00
#!/bin/bash
SCRIPT=$(readlink -f "$0")
INSTALLPATH=$(dirname "${SCRIPT}")
TOPDIR=$(dirname "${INSTALLPATH}")
default_ccnet_conf_dir=${TOPDIR}/ccnet
2019-12-03 03:09:00 +00:00
default_seafile_data_dir=${TOPDIR}/seafile-data
2019-12-03 06:00:20 +00:00
central_config_dir=${TOPDIR}/conf
2016-08-10 06:53:33 +00:00
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
2016-08-10 06:53:33 +00:00
echo
2019-08-16 04:11:18 +00:00
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
2016-08-10 06:53:33 +00:00
fi
}
2019-12-03 03:09:00 +00:00
function validate_seafile_data_dir () {
if [[ ! -d ${default_seafile_data_dir} ]]; then
2019-12-03 06:00:20 +00:00
echo "Error: there is no seafile server data directory."
echo "Have you run setup-seafile.sh before this?"
2016-08-10 06:53:33 +00:00
echo ""
exit 1;
fi
}
2021-10-21 10:16:23 +00:00
function prepare_seahub_log_dir() {
logdir=${TOPDIR}/logs
if ! [[ -d ${logsdir} ]]; then
if ! mkdir -p "${logdir}"; then
echo "ERROR: failed to create logs dir \"${logdir}\""
exit 1
fi
fi
export SEAHUB_LOG_DIR=${logdir}
}
2016-08-10 06:53:33 +00:00
check_python_executable;
2019-12-03 03:09:00 +00:00
validate_seafile_data_dir;
2021-10-21 10:16:23 +00:00
prepare_seahub_log_dir;
2016-08-10 06:53:33 +00:00
export CCNET_CONF_DIR=${default_ccnet_conf_dir}
2019-12-03 03:09:00 +00:00
export SEAFILE_CONF_DIR=${default_seafile_data_dir}
2016-08-10 06:53:33 +00:00
export SEAFILE_CENTRAL_CONF_DIR=${central_config_dir}
2021-10-11 09:08:19 +00:00
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3/site-packages:${INSTALLPATH}/seafile/lib64/python3/site-packages:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
2020-11-20 07:37:03 +00:00
export SEAFILE_RPC_PIPE_PATH=${INSTALLPATH}/runtime
2016-08-10 06:53:33 +00:00
manage_py=${INSTALLPATH}/seahub/manage.py
exec "$PYTHON" "$manage_py" createsuperuser