| 
									
										
										
										
											2021-12-03 15:35:16 +08:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SCRIPT=$(readlink -f "$0") | 
					
						
							|  |  |  | INSTALLPATH=$(dirname "${SCRIPT}") | 
					
						
							|  |  |  | TOPDIR=$(dirname "${INSTALLPATH}") | 
					
						
							|  |  |  | default_seafile_data_dir=${TOPDIR}/seafile-data | 
					
						
							|  |  |  | central_config_dir=${TOPDIR}/conf | 
					
						
							| 
									
										
										
										
											2021-12-04 10:45:09 +08:00
										 |  |  | pro_pylibs_dir=${INSTALLPATH}/pro/python | 
					
						
							|  |  |  | seafesdir=$pro_pylibs_dir/seafes | 
					
						
							| 
									
										
										
										
											2022-09-26 10:09:19 +08:00
										 |  |  | seahubdir=${INSTALLPATH}/seahub | 
					
						
							| 
									
										
										
										
											2021-12-03 15:35:16 +08: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 | 
					
						
							|  |  |  |         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." | 
					
						
							| 
									
										
										
										
											2023-01-14 08:02:39 +01:00
										 |  |  |             echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment variable to it" | 
					
						
							| 
									
										
										
										
											2021-12-03 15:35:16 +08:00
										 |  |  |             echo | 
					
						
							|  |  |  |             exit 1 | 
					
						
							|  |  |  |         fi | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function validate_seafile_data_dir () { | 
					
						
							|  |  |  |     if [[ ! -d ${default_seafile_data_dir} ]]; then | 
					
						
							|  |  |  |         echo "Error: there is no seafile server data directory." | 
					
						
							|  |  |  |         echo "Have you run setup-seafile.sh before this?" | 
					
						
							|  |  |  |         echo "" | 
					
						
							|  |  |  |         exit 1; | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function prepare_seahub_log_dir() { | 
					
						
							|  |  |  |     logdir=${TOPDIR}/logs | 
					
						
							| 
									
										
										
										
											2025-04-27 18:40:57 +02:00
										 |  |  |     if ! [[ -d ${logdir} ]]; then | 
					
						
							| 
									
										
										
										
											2021-12-03 15:35:16 +08:00
										 |  |  |         if ! mkdir -p "${logdir}"; then | 
					
						
							|  |  |  |             echo "ERROR: failed to create logs dir \"${logdir}\"" | 
					
						
							|  |  |  |             exit 1 | 
					
						
							|  |  |  |         fi | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |     export SEAHUB_LOG_DIR=${logdir} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | check_python_executable; | 
					
						
							|  |  |  | validate_seafile_data_dir; | 
					
						
							|  |  |  | prepare_seahub_log_dir; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export SEAFILE_CONF_DIR=${default_seafile_data_dir} | 
					
						
							|  |  |  | 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 | 
					
						
							| 
									
										
										
										
											2022-09-26 10:09:19 +08:00
										 |  |  | export SEAHUB_DIR=$seahubdir | 
					
						
							| 
									
										
										
										
											2021-12-03 15:35:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-04 10:45:09 +08:00
										 |  |  | if [[ -d ${INSTALLPATH}/pro ]]; then | 
					
						
							|  |  |  |     export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir | 
					
						
							|  |  |  |     export SEAFES_DIR=$seafesdir | 
					
						
							|  |  |  |     export SEAFILE_RPC_PIPE_PATH=${INSTALLPATH}/runtime | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-03 15:35:16 +08:00
										 |  |  | manage_py=${INSTALLPATH}/seahub/manage.py | 
					
						
							|  |  |  | exec "$PYTHON" "$manage_py" createsuperuser |