Last active
August 29, 2015 14:17
-
-
Save groucho75/d46dab5093be8632ac2b to your computer and use it in GitHub Desktop.
Create and setup a new WP blog using interactive wp-cli script
This file contains 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
#!/bin/bash | |
# Check wp-cli installed | |
type wp >/dev/null 2>&1 || { echo >&2 "This script requires wp-cli but it's not installed. Aborting."; exit 1; } | |
printf "\e[32mLet's go installing WP...\n\e[0m" | |
printf "\nTo install in a subfolder, write the folder name.\n" | |
echo "Otherwise leave empty to install in root:" | |
read folder | |
if [[ "$folder" != "" ]]; then | |
path_arg="--path=$folder" | |
else | |
path_arg="" | |
fi | |
printf "\nWrite the language code (e.g. it_IT, or empty):" | |
read locale | |
if [[ "$locale" != "" ]]; then | |
locale_arg="--locale=$locale" | |
else | |
locale_arg="" | |
fi | |
wp core download $path_arg $locale_arg | |
printf "\nPlease write the configurations...\n" | |
printf "DB_HOST (if empty: localhost):" | |
read dbhost | |
printf "DB_NAME:" | |
read dbname | |
printf "DB_USER:" | |
read dbuser | |
printf "DB_PASS:" | |
read dbpass | |
printf "Creating database if not exists yet..." | |
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS $dbname" | |
printf "done\n" | |
if [ -z "$dbhost" ]; then | |
dbhost="localhost" | |
fi | |
if [[ "$dbpass" != "" ]]; then | |
dbpass_arg="--dbpass=\"$dbpass\"" | |
else | |
dbpass_arg="" | |
fi | |
if [[ "$folder" != "" ]]; then | |
cd $folder | |
fi | |
printf "Creating config...\n" | |
wp core config --dbhost="$dbhost" --dbname="$dbname" --dbuser="$dbuser" $dbpass_arg $locale_arg --extra-php <<PHP | |
define( 'WP_DEBUG', true ); | |
define('FS_METHOD','direct'); | |
PHP | |
printf "\nPlease insert the info for installation...\n" | |
wp core install --prompt | |
# https://gist.github.com/morganestes/ddd76c6842000bdd7c89 | |
wp-beta() { | |
wp plugin install wordpress-beta-tester --activate | |
wp option set wp_beta_tester_stream unstable | |
wp core update | |
wp core version --extra | |
} | |
printf "\n" | |
while true; do | |
read -p "Would you like to a beta tester? (n,y)" yn | |
case $yn in | |
[Yy]* ) wp-beta; break;; | |
[Nn]* ) break;; | |
* ) echo "Please answer y or n.";; | |
esac | |
done | |
printf "\n\e[32mWP installing finished!\e[0m\n" | |
printf "\e[32mNow you can login as user you have chosen. Have fun!\e[0m\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment