Skip to content

Instantly share code, notes, and snippets.

@ricardobrg
Created May 28, 2016 12:39
Show Gist options
  • Save ricardobrg/a6f4732a69c3468ebbc87be908709911 to your computer and use it in GitHub Desktop.
Save ricardobrg/a6f4732a69c3468ebbc87be908709911 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Script to lauch WordPress Dev Site
NOME="$(date +%s%N | cut -b1-13)"
for i in "$@"
do
case $i in
-n=*|--nome=*)
NOME="${i#*=}"
shift #past argument=value
;;
esac
done
# Configurar variáveis
DBNAME=${NOME}
DBPASS="$(date +%s%N | cut -b1-13 | md5sum)"
USER="admin"
WPPASS="$(date +%s | md5sum)"
EMAIL="[email protected]"
HOME_URL = "http://dominio.com"
Q1="CREATE DATABASE IF NOT EXISTS db_$DBNAME;"
Q2="GRANT ALL ON *.* TO '$DBNAME'@'localhost' IDENTIFIED BY '$DBPASS';"
Q3="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}"
# Criação
mysql -uroot -p -e "$SQL"
wp core download --locale=pt_BR --path="/var/www/html/${NOME}"
sudo chown www-data:webmasters /var/www/html/${NOME} -R
cd /var/www/html/${NOME}
wp core config --dbname="db_${DBNAME}" --dbuser="${DBNAME}" --dbpass="${DBPASS}"
wp core install --url="${HOME_URL}/${NOME}" --title=${NOME} --admin_user=${USER} --admin_password=${WPPASS} --admin_email=${EMAIL}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment