seafilepro.sh 3.1 KB

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