seafilepro.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.2" [service]="dockerbunker/${SERVICE_NAME}" )
  17. declare -A BUILD_IMAGES=( [dockerbunker/${SERVICE_NAME}]="${DOCKERFILES}/${SERVICE_NAME}" )
  18. [[ -z $1 ]] && options_menu
  19. upgrade() {
  20. read -p "Please enter the Seafile Version number to upgrade to: " SF_VERSION
  21. pull_and_compare
  22. stop_containers
  23. remove_containers
  24. docker_run seafilepro_db_dockerbunker
  25. echo -e "\n\e[1mStarting up ${PROPER_NAME} upgrade container\e[0m" \
  26. && seafilepro_setup_dockerbunker "upgrade $SF_VERSION" \
  27. && exit_response
  28. docker_run_all
  29. }
  30. configure() {
  31. pre_configure_routine
  32. echo -e "# \e[4mSeafile Pro Settings\e[0m"
  33. set_domain
  34. # avoid tr illegal byte sequence in macOS when generating random strings
  35. if [[ $OSTYPE =~ "darwin" ]];then
  36. if [[ $LC_ALL ]];then
  37. oldLC_ALL=$LC_ALL
  38. export LC_ALL=C
  39. else
  40. export LC_ALL=C
  41. fi
  42. fi
  43. cat <<-EOF >> "${SERVICE_ENV}"
  44. # ------------------------------
  45. # General Settings
  46. # ------------------------------
  47. PROPER_NAME="${PROPER_NAME}"
  48. SERVICE_NAME=${SERVICE_NAME}
  49. SSL_CHOICE=${SSL_CHOICE}
  50. LE_EMAIL=${LE_EMAIL}
  51. SERVICE_DOMAIN=${SERVICE_DOMAIN}
  52. # ------------------------------
  53. # SQL database configuration
  54. # ------------------------------
  55. DBUSER=seafile
  56. # Please use long, random alphanumeric strings (A-Za-z0-9)
  57. DBROOT=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  58. DBPASS=$(</dev/urandom tr -dc A-Za-z0-9 | head -c 28)
  59. EOF
  60. if [[ $OSTYPE =~ "darwin" ]];then
  61. unset LC_ALL
  62. fi
  63. post_configure_routine
  64. }
  65. setup() {
  66. initial_setup_routine
  67. SUBSTITUTE=( "\${SERVICE_DOMAIN}" )
  68. basic_nginx
  69. [[ $keep_volumes ]] \
  70. && echo -en "\n\e[1mStarting up ${PROPER_NAME} database container\e[0m" \
  71. && seafilepro_db_dockerbunker \
  72. && exit_response
  73. if [[ -z $keep_volumes ]];then
  74. echo "Starting interactive Seafile Pro setup"
  75. echo ""
  76. echo "MySQL Server: db"
  77. echo "Port: 3306"
  78. echo "MySQL User: seafile"
  79. prompt_confirm "Display MySQL root and user passwords"
  80. [[ $? == 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"
  81. echo ""
  82. echo -e "\n\e[1mStarting up ${PROPER_NAME} setup container\e[0m" \
  83. && docker_run seafilepro_db_dockerbunker \
  84. && seafilepro_setup_dockerbunker setup \
  85. && exit_response
  86. fi
  87. docker_run_all
  88. post_setup_routine
  89. }
  90. if [[ $1 == "letsencrypt" ]];then
  91. $1 $*
  92. else
  93. $1
  94. fi