seafilepro.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #!/usr/bin/env bash
  2. while true;do ls | grep -q dockerbunker.sh;if [[ $? == 0 ]];then BASE_DIR=$PWD;break;else cd ../;fi;done
  3. PROPER_NAME="Seafile Pro"
  4. SERVICE_NAME="$(echo -e "${PROPER_NAME,,}" | tr -d '[:space:]')"
  5. PROMPT_SSL=true
  6. safe_to_keep_volumes_when_reconfiguring=1
  7. declare -a environment=( "data/env/dockerbunker.env" "data/include/init.sh" )
  8. for env in "${environment[@]}";do
  9. [[ -f "${BASE_DIR}"/$env ]] && source "${BASE_DIR}"/$env
  10. done
  11. declare -A WEB_SERVICES
  12. declare -a containers=( "${SERVICE_NAME}-db-dockerbunker" "${SERVICE_NAME}-service-dockerbunker" )
  13. declare -a add_to_network=( "${SERVICE_NAME}-service-dockerbunker" )
  14. declare -A volumes=( [${SERVICE_NAME}-data-vol-1]="/seafile" [${SERVICE_NAME}-db-vol-1]="/var/lib/mysql" )
  15. declare -a networks=( "dockerbunker-${SERVICE_NAME}" )
  16. declare -A IMAGES=( [db]="mariadb:10.3" [service]="chaosbunker/seafile-pro-docker" )
  17. current_version="6.3.14"
  18. [[ -z $1 ]] && options_menu
  19. upgrade() {
  20. pull_and_compare
  21. stop_containers
  22. remove_containers
  23. docker_run seafilepro_db_dockerbunker
  24. seafilepro_setup_dockerbunker "upgrade ${current_version}"
  25. docker_run_all
  26. [[ -z ${FILE_COMMENT_MIGRATED} ]] \
  27. && echo -e "\n\e[1mMigrate database table for file comments\e[0m" \
  28. && docker exec -it seafilepro-service-dockerbunker ./seahub.sh python-env seahub/manage.py migrate_file_comment \
  29. && exit_response \
  30. && echo "FILE_COMMENT_MIGRATED=1" >> "${ENV_DIR}"/${SERVICE_NAME}.env
  31. echo -e "\n\e[1mRunning mysql_upgrade on all databases\e[0m"
  32. docker exec -it seafilepro-db-dockerbunker mysql_upgrade -u root -p${DBROOT}
  33. }
  34. configure() {
  35. pre_configure_routine
  36. echo -e "# \e[4mSeafile Pro Settings\e[0m"
  37. set_domain
  38. # avoid tr illegal byte sequence in macOS when generating random strings
  39. if [[ $OSTYPE =~ "darwin" ]];then
  40. if [[ $LC_ALL ]];then
  41. oldLC_ALL=$LC_ALL
  42. export LC_ALL=C
  43. else
  44. export LC_ALL=C
  45. fi
  46. fi
  47. cat <<-EOF >> "${SERVICE_ENV}"
  48. # ------------------------------
  49. # General Settings
  50. # ------------------------------
  51. PROPER_NAME="${PROPER_NAME}"
  52. SERVICE_NAME=${SERVICE_NAME}
  53. SSL_CHOICE=${SSL_CHOICE}
  54. LE_EMAIL=${LE_EMAIL}
  55. SERVICE_DOMAIN=${SERVICE_DOMAIN}
  56. # ------------------------------
  57. # SQL database configuration
  58. # ------------------------------
  59. DBUSER=seafile
  60. # Please use long, random alphanumeric strings (A-Za-z0-9)
  61. DBROOT=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  62. DBPASS=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  63. EOF
  64. if [[ $OSTYPE =~ "darwin" ]];then
  65. unset LC_ALL
  66. fi
  67. post_configure_routine
  68. }
  69. setup() {
  70. initial_setup_routine
  71. SUBSTITUTE=( "\${SERVICE_DOMAIN}" )
  72. basic_nginx
  73. [[ $keep_volumes ]] \
  74. && echo -en "\n\e[1mStarting up ${PROPER_NAME} database container\e[0m" \
  75. && seafilepro_db_dockerbunker \
  76. && exit_response
  77. if [[ -z $keep_volumes ]];then
  78. echo "Starting interactive Seafile Pro setup"
  79. echo ""
  80. echo "MySQL Server: db"
  81. echo "Port: 3306"
  82. echo "MySQL User: seafile"
  83. prompt_confirm "Display MySQL root and user passwords"
  84. [[ $? == 0 ]] && echo -e "MySQL root password: ${DBROOT}\nMySQL user password: ${DBPASS}" || echo -e "\e[33mPlease obtain the MySQL root password from ${SERVICE_ENV}\e[0m\n"
  85. echo ""
  86. echo -e "\n\e[1mStarting up ${PROPER_NAME} setup container\e[0m" \
  87. && docker_run seafilepro_db_dockerbunker \
  88. && seafilepro_setup_dockerbunker setup \
  89. && exit_response
  90. fi
  91. docker_run_all
  92. post_setup_routine
  93. }
  94. if [[ $1 == "letsencrypt" ]];then
  95. $1 $*
  96. else
  97. $1
  98. fi