Skip to content

Instantly share code, notes, and snippets.

@hitaboy
Forked from bgallagh3r/wp.sh
Last active February 7, 2016 16:56
Show Gist options
  • Save hitaboy/38d1ba284c5fe9d58177 to your computer and use it in GitHub Desktop.
Save hitaboy/38d1ba284c5fe9d58177 to your computer and use it in GitHub Desktop.
Wordpress: Bash Install Script -- Downloads latest WP version, updates wp-config with user supplied DB name, username and password, creates and CHMOD's uploads dir, copies all the files into the root dir you run the script from, then deletes itself!
#!/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 "Create database? (y/n)"
read -e createdatabase
if [ "$createdatabase" == n ] ; then
echo "create database $dbname" | mysql -u root -p
fi
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
tar -zxvf latest.tar.gz
#change dir to wordpress
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
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
#set WP salts
perl -i -pe'
BEGIN {
@chars = ("a" .. "z", "A" .. "Z", 0 .. 9);
push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|";
sub salt { join "", map $chars[ rand @chars ], 1 .. 64 }
}
s/put your unique phrase here/salt()/ge
' wp-config.php
#create uploads folder and set permissions
mkdir wp-content/uploads
chmod 777 wp-content/uploads
echo "Template name: "
read -e templatename
cd wp-content/themes/
rm -rf *
git clone -b htemplates https://github.com/hitaboy/hodiern-wpblanktheme.git
echo "Cleaning..."
mv hodiern-wpblanktheme $templatename
cd ../..
#remove zip file
rm latest.tar.gz
#remove bash script
rm wp.sh
echo "========================="
echo "Installation is complete."
echo "========================="
fi
@hitaboy
Copy link
Author

hitaboy commented Oct 19, 2015

Pendent dinamitzar el nom de template y el browser-sync del gulp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment