Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash -e
clear
echo "============================================"
echo "Instalador de Wordpress"
echo "============================================"
echo "Host do Banco de dados: "
read -e dbhost
echo "Nome do Banco de dados: "
read -e dbname
echo "Usúario do Banco de dados: "
read -e dbuser
echo "Senha do Banco de dados: "
read -s dbpass
echo "============================================"
echo "Vou validar o Banco de dados"
echo "============================================"
# mysql="mysql --host=$dbhost --user=$dbuser --password=$dbpass -s -N --execute="SELECT IF(EXISTS (SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$dbname'), 'Yes','No')";"
mysql=`mysqlshow --host=$dbhost --user=$dbuser --password=$dbpass $dbname| grep -v Wildcard | grep -o $dbname`
if [ "$mysql" == "$dbname" ]; then
echo "Esse banco de dados já existe, deseja usar ele? (y/n)"
read -e usethis
if [ "$usethis" == n ]; then
echo "Recomece para selecionar outro banco de dados."
echo "Precione qualquer tecla para sair..."
read -s exit
exit
fi
else
mysql=`mysql --host=$dbhost --user=$dbuser --password=$dbpass --execute="CREATE DATABASE $dbname";`
echo "============================================"
echo "Banco de dados criado!"
echo "============================================"
fi
echo "Começar a isntalação? (y/n)"
read -e run
if [ "$run" == n ] ; then
exit
else
echo "===================================================="
echo "O script está instalação o Wordpress, aguarde..."
echo "===================================================="
#Faz o download da bagaça
curl -O https://wordpress.org/latest.tar.gz
#dezipa
tar -zxvf latest.tar.gz
#vai pro dir do wordpress
cd wordpress
#copia pro diretório de cima
cp -rf . ..
#vai pro diretório de cima
cd ..
#exclui as coisas do diretório do wordpress
rm -R wordpress
#cria o wp config
cp wp-config-sample.php wp-config.php
#sobreescreve as configs do db
perl -pi -e "s/database_name_here/$dbname/g" wp-config.php
perl -pi -e "s/username_here/$dbuser/g" wp-config.php
perl -pi -e "s/password_here/$dbpass/g" wp-config.php
#define WP salts (WTF??)
perl -i -pe'
BEGIN {
@chars = ("a" .. "z", "A" .. "Z", 0 .. 9);
push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|";
sub salt { join "", map $chars[ rand @chars ], 1 .. 64 }
}
s/chagasfe/salt()/ge
' wp-config.php
#cria as pastas de upload e da a permissão
mkdir wp-content/uploads
chmod 775 wp-content/uploads
echo "Limpando a bagunça..."
#exclui o zip
rm latest.tar.gz
#remove o script
rm wp.sh
echo "========================="
echo "Instalação completa!"
echo "========================="
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.