Created
January 13, 2021 01:30
-
-
Save pwillis-els/0855fc83e29495a6ab3805e5d1b5c682 to your computer and use it in GitHub Desktop.
Friendly shell interface for generating a new Bedrock (WordPress) instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
[ "${DEBUG:-0}" = "1" ] && set -x | |
[ -n "${PROJECT_NAME:-}" ] || read -r -p "Project name [wordpress]: " PROJECT_NAME | |
[ -n "${PROJECT_NAME:-}" ] || PROJECT_NAME="wordpress" | |
[ -n "${WP_HOME:-}" ] || read -r -p "Website URL [https://localsite.localdomain]: " WP_HOME | |
[ -n "${WP_HOME:-}" ] || WP_HOME="https://localsite.localdomain" | |
[ -n "${WP_SITEURL:-}" ] || read -r -p "Wordpress URL [https://localsite.localdomain/wp]: " WP_SITEURL | |
[ -n "${WP_SITEURL:-}" ] || WP_HOME="https://localsite.localdomain/wp" | |
[ -n "${DB_HOST:-}" ] || read -r -p "Database host [localhost]: " DB_HOST | |
[ -n "${DB_HOST:-}" ] || DB_HOST="localhost" | |
[ -n "${DB_NAME:-}" ] || read -r -p "Database name [wordpress]: " DB_NAME | |
[ -n "${DB_NAME:-}" ] || DB_NAME="wordpress" | |
[ -n "${DB_USER:-}" ] || read -r -p "Database user [wpuser]: " DB_USER | |
[ -n "${DB_USER:-}" ] || DB_USER="wpuser" | |
[ -n "${DB_PASSWORD:-}" ] || read -r -p "Database password [wppassword]: " DB_PASSWORD | |
[ -n "${DB_PASSWORD:-}" ] || DB_PASSWORD="wppassword" | |
docker run --rm -it -v `pwd`:/app -u `id -u`:`id -g` composer create-project roots/bedrock | |
cd bedrock | |
cat .env | grep -v generateme > .env.new | |
sed -i -e "s?database_name?$DB_NAME?g" .env.new | |
sed -i -e "s?database_user?$DB_USER?g" .env.new | |
sed -i -e "s?database_password?$DB_PASSWORD?g" .env.new | |
sed -i -e "s?^# DB_HOST=.*?DB_HOST=$DB_HOST?g" .env.new | |
sed -i -e "s?^ DB_PREFIX=.*?DB_PREFIX=wp_?g" .env.new | |
sed -i -e "s?^WP_HOME=.*?WP_HOME=$WP_HOME?g" .env.new | |
sed -i -e "s?^WP_DEBUG_LOG=.*?WP_DEBUG_LOG=\/var\/log\/wordpress.log?g" .env.new | |
printf "\n" >> .env.new | |
curl -sLo - https://api.wordpress.org/secret-key/1.1/salt/ | sed -e "s/^define('//g; s/',[[:space:]]\+/=/g; s/');/'/g" >> .env.new | |
mv .env.new .env |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment