Skip to content

Instantly share code, notes, and snippets.

@DKudleichuk
Created March 7, 2022 06:59
Show Gist options
  • Save DKudleichuk/3f6980b3dc027048eef18bb8c9e04dcd to your computer and use it in GitHub Desktop.
Save DKudleichuk/3f6980b3dc027048eef18bb8c9e04dcd to your computer and use it in GitHub Desktop.
WordPress Bash installation script
#!/bin/bash -e
alias wp=/e/srv/wp-cli/wp.bat
PATH=$PATH:wp;
clear
echo "Welcome to WordPress auto installer!"
echo "Enter Site Title (question 1/5 ):"
read PROJECT_NAME
echo "Enter Current Project URL (e.g. http://localhost) (question 2/5 ):"
read PROJECT_URL
echo "Enter Database Name (question 3/5 ):"
read DB_NAME
echo "Enter Database User (question 4/5 ):"
read DB_USER
echo "Enter Database Password (question 5/5 ):"
read DB_PASS
echo "Downloading the latest version of WordPress..."
wp core download
echo "Creating WP Config.php"
cp wp-config-sample.php wp-config.php
sed -i bak -e "s/database_name_here/$DB_NAME/" wp-config.php
sed -i bak -e "s/username_here/$DB_USER/" wp-config.php
sed -i bak -e "s/password_here/$DB_PASS/" wp-config.php
sed -i bak -e "s/define( 'WP_DEBUG', false );/define( 'WP_DEBUG', false );\ndefine( 'WP_DEBUG_LOG', true );\ndefine( 'WP_DEBUG_DISPLAY', false );/" wp-config.php
echo "Success: Generated 'wp-config.php' file."
echo "Installing core..."
wp core install --url=$PROJECT_URL --title="$PROJECT_NAME" --admin_user=admin --admin_password=admin --admin_email=admin@localhost.lc
echo "Delete sample post"
wp post delete $(wp post list --post_type=page --posts_per_page=1 --post_status=publish --pagename="sample-page" --field=ID)
echo "Rewrite post url structure"
wp rewrite structure '/%postname%/' --hard
wp rewrite flush --hard
echo "Deleting default plugins..."
wp plugin delete akismet hello
echo "Activating Our Boilerplate Theme..."
wp theme activate bilberrry
echo "Deleting all default themes..."
wp theme delete twentynineteen twentytwenty twentytwentyone twentytwentytwo
echo "Installing Gulp and dependencies"
npm i
echo "---------------------------------"
echo "WordPress installed successfully!"
echo "---------------------------------"
echo "Admin login: admin"
echo "Admin password: admin"
echo "---------------------------------"
# do not close automatically
read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment