install.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. case "${DBMS}" in
  3. 'postgres')
  4. PGPASSWORD="${POSTGRES_PASSWORD}" psql -ltq -Upostgres -hdb | \
  5. cut -d '|' -f1 | grep -wq "${SOCIAL_DB}"
  6. DB_EXISTS=$?
  7. DB_TYPE='pgsql'
  8. SOCIAL_USER=postgres
  9. # Create database, if it doesn't exits
  10. [ ! ${DB_EXISTS} ] || PGPASSWORD="${POSTGRES_PASSWORD}" psql -Upostgres -hdb -c "create database ${SOCIAL_DB};"
  11. ;;
  12. 'mariadb')
  13. mysqlcheck -cqs -uroot "-p${MYSQL_ROOT_PASSWORD}" -hdb social 2> /dev/null
  14. DB_EXISTS=$?
  15. DB_TYPE='mysql'
  16. ;;
  17. *)
  18. echo "Unknown DBMS"
  19. exit 1
  20. esac
  21. if [ ! ${DB_EXISTS} ] || [ ! -e /var/www/social/config.php ]; then
  22. printf 'Installing GNU social\nInstalling composer dependencies'
  23. cd /var/www/social || exit 1
  24. composer install
  25. chmod g+w -R .
  26. chown -R :www-data .
  27. php /var/www/social/scripts/install_cli.php --dbtype="${DB_TYPE}" --server="${SOCIAL_DOMAIN}" --sitename="${SOCIAL_SITENAME}" \
  28. --host=db --fancy=yes --database="${SOCIAL_DB}" \
  29. --username="${SOCIAL_USER}" --password="${SOCIAL_PASSWORD}" \
  30. --admin-nick="${SOCIAL_ADMIN_NICK}" --admin-pass="${SOCIAL_ADMIN_PASSWORD}" || exit 1
  31. echo "GNU social is installed"
  32. fi