From 5a61098d28bf66ef5ef023baf474c5e0d0edb3f2 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sat, 16 May 2020 12:37:06 +0000 Subject: [PATCH] [TOOLS] Update install scripts --- .php_cs | 2 ++ bin/bootstrap_certificates | 9 +++++--- bin/configure | 43 +++++++++++++++++++++++------------ docker/bootstrap/bootstrap.sh | 1 - docker/social/install.sh | 14 ++++++++---- 5 files changed, 46 insertions(+), 23 deletions(-) diff --git a/.php_cs b/.php_cs index fbb85251e5..99a0a184a4 100644 --- a/.php_cs +++ b/.php_cs @@ -271,6 +271,8 @@ return PhpCsFixer\Config::create() ->setFinder(PhpCsFixer\Finder::create() ->exclude('vendor') ->exclude('var') + ->exclude('docker') ->exclude('src/Entity') + ->notPath('src/Core/DefaultSettings.php') ->in(__DIR__) ); diff --git a/bin/bootstrap_certificates b/bin/bootstrap_certificates index 30dd538061..1b9a0dd6bf 100755 --- a/bin/bootstrap_certificates +++ b/bin/bootstrap_certificates @@ -4,14 +4,17 @@ printf "Domain root: " read -r domain_root printf "Subdomain (can be empty): " read -r sub_domain -printf "Email: " -read -r email -printf "Use certificate signed by Let's Encrypt (Y/n): " read -r signed +printf "Use certificate signed by Let's Encrypt (Y/n): " [ "${signed}" = "${signed#[Yy]}" ] signed=$? +if [ $signed ]; then + printf "Email: " + read -r email +fi + if [ -z "$sub_domain" ] then domain="${domain_root}" diff --git a/bin/configure b/bin/configure index b109ba6595..e197d0d9d2 100755 --- a/bin/configure +++ b/bin/configure @@ -1,22 +1,36 @@ #!/bin/sh +git_dir=$PWD +while [ ! -d .git ]; do + git_dir=$(dirname "${git_dir}") +done + +cd "${git_dir}" || exit + . ./docker/bootstrap/bootstrap.env -read -p "DBMS (postgres|mariadb): " dbms -read -p "DB root password: " db_root_password -read -p "Social database name: " db -read -p "Database user: " user -read -p "Database password: " password -read -p "Sitename: " sitename -read -p "Admin nickname: " admin_nick -read -p "Admin password: " admin_password -read -p "Site profile (public|private|community|singleuser): " profile + +while :; do + printf "DBMS (postgres|mariadb): " && read -r dbms + [ $(echo "${dbms}" | grep -E 'postgres|mariadb') ] && break +done + +printf "Social database name: " && read -r db +[ "${dbms}" = 'mariadb' ] && printf "Database user: " && read -r user +printf "Database password: " && read -r password +printf "Sitename: " && read -r sitename +printf "Admin nickname: " && read -r admin_nick +printf "Admin password: " && read -r admin_password + +while :; do + printf "Site profile (public|private|community|singleuser): " && read -r profile + [ $(echo "${profile}" | grep -E 'public|private|community|singleuser') ] && break +done mkdir -p ./docker/db - -if [ ${dbms} = 'mariadb' ]; then - read -p "DB root password: " db_root_password +if [ "${dbms}" = 'mariadb' ]; then + printf "DB root password: " && read -r db_root_password cat > ./docker/db/db.env < ./docker/db/db.env < .env.local +echo "${database_url}" > .env.local mkdir -p ./docker/social diff --git a/docker/bootstrap/bootstrap.sh b/docker/bootstrap/bootstrap.sh index cc4653f7ac..5b86c9aad1 100755 --- a/docker/bootstrap/bootstrap.sh +++ b/docker/bootstrap/bootstrap.sh @@ -28,7 +28,6 @@ then -keyout "${lets_path}/live/${domain_root}/privkey.pem" \ -out "${lets_path}/live/${domain_root}/fullchain.pem" -subj "/CN=${domain_root}" - nginx -s reload else echo "### Creating dummy certificate for ${domain_root} ..." openssl req -x509 -nodes -newkey rsa:1024 -days 1 \ diff --git a/docker/social/install.sh b/docker/social/install.sh index a7044d89cb..77db365938 100755 --- a/docker/social/install.sh +++ b/docker/social/install.sh @@ -3,11 +3,11 @@ case "${DBMS}" in 'postgres') PGPASSWORD="${POSTGRES_PASSWORD}" psql -ltq -Upostgres -hdb | \ - cut -d '|' -f1 | grep -wq "${SOCIAL_DB}" + cut -d '|' -f1 | grep -Fwq "${SOCIAL_DB}" DB_EXISTS=$? ;; 'mariadb') - mysqlcheck -cqs -uroot -p${MYSQL_ROOT_PASSWORD} -hdb social 2> /dev/null + mysqlcheck -cqs -uroot -p"${MYSQL_ROOT_PASSWORD}" -hdb social 2> /dev/null DB_EXISTS=$? exit 1 ;; @@ -16,11 +16,12 @@ case "${DBMS}" in exit 1 esac -if [ ! ${DB_EXISTS} ]; then +if [ ${DB_EXISTS} -ne 0 ]; then - echo -e "Installing GNU social\nInstalling composer dependencies" + echo "Installing GNU social" + echo "Installing composer dependencies" - cd /var/www/social + cd /var/www/social || exit 1 composer install @@ -28,6 +29,9 @@ if [ ! ${DB_EXISTS} ]; then chown -R :www-data . php bin/console doctrine:database:create || exit 1 + php bin/console doctrine:schema:create || exit 1 echo "GNU social is installed" +else + echo "GNU social is already installed" fi