Skip to content

Instantly share code, notes, and snippets.

@upbeta01
Created September 8, 2017 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save upbeta01/d56f6a845e57ef89f35ce3525204ec9a to your computer and use it in GitHub Desktop.
Save upbeta01/d56f6a845e57ef89f35ce3525204ec9a to your computer and use it in GitHub Desktop.
#!/bin/bash
# Author name: Ruel Nopal
# Company: RaketHost PH Inc.
# url: www.rakethost.ph
echo "Input the full path of your Wordpress installation folder..."
echo "If you don't know the detail, run <pwd> command from the Wordpress installation folder and the path will be output."
echo "It should be something like </home/user/wordpress> or </var/www/wordpress>"
echo "Enter Wordpress Path: "
read wordpress_path
if [ -z "$wordpress_path" ]; then
exit 1
fi
echo "Create a folder to store the important files?. The Default path is /tmp"
echo "Input folder name: "
read folder_name
if [ -z "$folder_name" ]; then
exit 1
fi
echo "Creating the folder /tmp/$folder_name ..."
mkdir /tmp/$folder_name
echo "Folder /tmp/$folder_name has been created"
echo "Moving the $wordpress_path/wp-content to the /tmp/$folder_name ..."
mv $wordpress_path/wp-content /tmp/$folder_name
echo "Successfully moved $wordpress_path/wp-content to /tmp/$folder_name"
echo "Moving $wordpress_path/wp-config.php to /tmp/$folder_name ..."
mv $wordpress_path/wp-config.php /tmp/$folder_name
echo "Successfully moved $wordpress_path/wp-config.php"
echo -e ""
echo -e ""
echo -e ""
echo "The next step requires the existing wordpress files to be delete."
echo "If you have important files that you don't have backup, please don't proceed."
read -p "Do you wish to proceed? [y/n] " yn
case $yn in
[Yy]* ) rm -rf $wordpress_path/*; break;;
* ) exit 1;;
esac
echo "Downloading fresh Wordpress files ..."
wget https://wordpress.org/latest.zip
echo "Download complete"
echo "Unzipping the Wordpress files ..."
unzip latest.zip
echo "Unzipping, complete"
echo "Moving the fresh Wordpress files to $wordpress_path ..."
mv wordpress/* $wordpress_path
echo "Moving of fresh Wordpress files, complete"
echo "Deleting default wp-content folder ..."
rm -rf $wordpress_path/wp-content
echo "Successfully deleted"
echo "Restoring the important files ..."
mv /tmp/$folder_name/wp-content /tmp/$folder_name/wp-config.php $wordpress_path
echo "Restoration complete"
echo "Cleaning un-utilized files/folders ..."
rm -rf latest.zip
rm -rf wordpress
echo "Please check your site ..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment