Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This script will re-install the latest wordpress core files
- # A database dump will be made to database-bk.sql
- # Run this script while in public_html folder
- # !/bin/bash
- if [ -d backup ] ; then
- echo "You already have a backup folder! Please rename it before attempting to run this tool."
- exit
- else
- mkdir backup
- fi
- if [ -e latest.tar.gz ]; then
- echo "It seems the latest.tar.gz file already exists. Please remove or rename it before attempting to run this tool."
- exit
- else
- wget http://wordpress.org/latest.tar.gz
- if [ -d wordpress ]; then
- echo "It seems there is a wordpress folder already created. Please remove or rename it before attempting to run this tool."
- else
- tar -xvf latest.tar.gz
- cd wordpress
- # remove wp-content so the users data is not overwritten or lost at any point.
- rm -rf wp-content
- # loop through each file in latest tarball to see if it already exists
- for f in $(ls); do
- old="../"
- old=$old$f
- # if the file from the archive exists already, then move it to the backup folder
- if [ -e $old ] ; then mv $old ../backup ; fi
- # move new file from latest tar up one folder to the site folder
- mv $f ../
- done
- echo "Your WordPress core files have been re-installed. The old core files are in the backup folder."
- fi
- # clean up the leftover files . original core files will be in the backup folder in the documentroot
- cd ../ ; rm -rf wordpress ; rm -rf latest.tar.gz
- if [ -e wp-config.php ] ; then
- user=`grep DB_USER wp-config.php|cut -d\' -f4`;db=`grep DB_NAME wp-config.php|cut -d\' -f4`;pass=`grep DB_PASSWORD wp-config.php|cut -d\' -f4`;
- mysqldump -u $user -p $db --password=$pass > backup/database-bk.sql
- echo "Your database has been saved to backup/database-bk.sql"
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement