commento.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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="Commento"
  4. SERVICE_NAME="$(echo -e "${PROPER_NAME,,}" | tr -d '[:space:]')"
  5. PROMPT_SSL=1
  6. declare -a environment=( "data/env/dockerbunker.env" "data/include/init.sh" )
  7. for env in "${environment[@]}";do
  8. [[ -f "${BASE_DIR}"/$env ]] && source "${BASE_DIR}"/$env
  9. done
  10. declare -A WEB_SERVICES
  11. declare -a containers=( "commento-postgres-dockerbunker" "${SERVICE_NAME}-service-dockerbunker" )
  12. declare -a add_to_network=( "commento-service-dockerbunker" )
  13. declare -A volumes=( [${SERVICE_NAME}-db-vol-1]="/var/lib/postgresql/data" )
  14. declare -a networks=( "dockerbunker-commento" )
  15. declare -A IMAGES=( [postgres]="postgres" [service]="registry.gitlab.com/commento/commento" )
  16. [[ -z $1 ]] && options_menu
  17. configure() {
  18. pre_configure_routine
  19. echo -e "# \e[4mCommento Settings\e[0m"
  20. set_domain
  21. configure_mx
  22. prompt_confirm "Set up Github OAuth"
  23. if [[ $? == 0 ]];then
  24. read -p "Client ID: " -ei "" COMMENTO_GITHUB_KEY
  25. read -p "Client Secret: " -ei "" COMMENTO_GITHUB_SECRET
  26. fi
  27. prompt_confirm "Set up Gitlab OAuth"
  28. if [[ $? == 0 ]];then
  29. read -p "Client ID: " -ei "" COMMENTO_GITLAB_KEY
  30. read -p "Client Secret: " -ei "" COMMENTO_GITLAB_SECRET
  31. fi
  32. prompt_confirm "Set up Google OAuth"
  33. if [[ $? == 0 ]];then
  34. read -p "Client ID: " -ei "" COMMENTO_GOOGLE_KEY
  35. read -p "Client Secret: " -ei "" COMMENTO_GOOGLE_SECRET
  36. fi
  37. prompt_confirm "Set up Twitter OAuth"
  38. if [[ $? == 0 ]];then
  39. read -p "Client ID: " -ei "" COMMENTO_TWITTER_KEY
  40. read -p "Client Secret: " -ei "" COMMENTO_TWITTER_SECRET
  41. fi
  42. # avoid tr illegal byte sequence in macOS when generating random strings
  43. if [[ $OSTYPE =~ "darwin" ]];then
  44. if [[ $LC_ALL ]];then
  45. oldLC_ALL=$LC_ALL
  46. export LC_ALL=C
  47. else
  48. export LC_ALL=C
  49. fi
  50. fi
  51. cat <<-EOF >> "${SERVICE_ENV}"
  52. # ------------------------------
  53. # General Settings
  54. # ------------------------------
  55. PROPER_NAME="${PROPER_NAME}"
  56. SERVICE_NAME=${SERVICE_NAME}
  57. SSL_CHOICE=${SSL_CHOICE}
  58. LE_EMAIL=${LE_EMAIL}
  59. SERVICE_DOMAIN=${SERVICE_DOMAIN}
  60. SERVICE_SPECIFIC_MX=${SERVICE_SPECIFIC_MX}
  61. COMMENTO_FORBID_NEW_OWNERS=false
  62. COMMENTO_ORIGIN=https://${SERVICE_DOMAIN}
  63. COMMENTO_GITHUB_KEY=${COMMENTO_GITHUB_KEY}
  64. COMMENTO_GITHUB_SECRET=${COMMENTO_GITHUB_SECRET}
  65. COMMENTO_GITLAB_KEY=${COMMENTO_GITLAB_KEY}
  66. COMMENTO_GITLAB_SECRET=${COMMENTO_GITLAB_SECRET}
  67. COMMENTO_GOOGLE_KEY=${COMMENTO_GOOGLE_KEY}
  68. COMMENTO_GOOGLE_SECRET=${COMMENTO_GOOGLE_SECRET}
  69. COMMENTO_TWITTER_KEY=${COMMENTO_TWITTER_KEY}
  70. COMMENTO_TWITTER_SECRET=${COMMENTO_TWITTER_SECRET}
  71. COMMENTO_CONFIG_FILE=/etc/commento.env
  72. # ------------------------------
  73. # SQL database configuration
  74. # ------------------------------
  75. DBUSER=commento
  76. # Please use long, random alphanumeric strings (A-Za-z0-9)
  77. DBPASS=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 28)
  78. EOF
  79. if [[ $OSTYPE =~ "darwin" ]];then
  80. [[ $oldLC_ALL ]] && export LC_ALL=$oldLC_ALL || unset LC_ALL
  81. fi
  82. post_configure_routine
  83. }
  84. if [[ $1 == "letsencrypt" ]];then
  85. $1 $*
  86. else
  87. $1
  88. fi