Skip to content

Instantly share code, notes, and snippets.

@touhidshaikh
Created September 12, 2020 11:16
Show Gist options
  • Save touhidshaikh/eab0ed218997cc25a77a3892eb7d0b48 to your computer and use it in GitHub Desktop.
Save touhidshaikh/eab0ed218997cc25a77a3892eb7d0b48 to your computer and use it in GitHub Desktop.
Automatically Wordpress Installer
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Database Name: "
read -e dbname
echo "Database User: "
read -e dbuser
echo "Database Password: "
read -s dbpass
echo "Database Host: "
read -s dbhost
echo "run install? (y/n)"
read -e run
if [ "$run" == n ] ; then
exit
else
echo "============================================"
echo "A robot is now installing WordPress for you."
echo "============================================"
#download wordpress
curl -O https://wordpress.org/latest.tar.gz
#unzip wordpress and move
tar -zxvf latest.tar.gz && cd wordpress
#copy file to parent dir
cp -rf . ..
#move back to parent dir
cd ..
#remove files from wordpress folder
rm -R wordpress
#create wp config
cp wp-config-sample.php wp-config.php
#set database details with perl find and replace
sed -i "s/database_name_here/$dbname/g" wp-config.php
sed -i "s/username_here/$dbuser/g" wp-config.php
sed -i "s/password_here/$dbpass/g" wp-config.php
sed -i "s/localhost/$dbhost/g" wp-config.php
#create uploads folder and set permissions
mkdir wp-content/uploads
chmod 775 wp-content/uploads
echo "Cleaning..."
#remove zip file
rm latest.tar.gz
#remove bash script
rm wp.sh
echo "========================="
echo "Installation is complete."
echo "========================="
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment