Advertisement
Guest User

wp core replacer

a guest
Dec 8th, 2016
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. # This script will re-install the latest wordpress core files
  2. # A database dump will be made to database-bk.sql
  3. # Run this script while in public_html folder
  4.  
  5. # !/bin/bash
  6.  
  7. if [ -d backup ] ; then
  8. echo "You already have a backup folder! Please rename it before attempting to run this tool."
  9. exit
  10. else
  11. mkdir backup
  12. fi
  13.  
  14. if [ -e latest.tar.gz ]; then
  15. echo "It seems the latest.tar.gz file already exists. Please remove or rename it before attempting to run this tool."
  16. exit
  17. else
  18. wget http://wordpress.org/latest.tar.gz
  19. if [ -d wordpress ]; then
  20. echo "It seems there is a wordpress folder already created. Please remove or rename it before attempting to run this tool."
  21. else
  22. tar -xvf latest.tar.gz
  23. cd wordpress
  24.  
  25. # remove wp-content so the users data is not overwritten or lost at any point.
  26. rm -rf wp-content
  27.  
  28. # loop through each file in latest tarball to see if it already exists
  29. for f in $(ls); do
  30. old="../"
  31. old=$old$f
  32.  
  33. # if the file from the archive exists already, then move it to the backup folder
  34. if [ -e $old ] ; then mv $old ../backup ; fi
  35.  
  36. # move new file from latest tar up one folder to the site folder
  37. mv $f ../
  38. done
  39. echo "Your WordPress core files have been re-installed. The old core files are in the backup folder."
  40.  
  41. fi
  42. # clean up the leftover files . original core files will be in the backup folder in the documentroot
  43. cd ../ ; rm -rf wordpress ; rm -rf latest.tar.gz
  44.  
  45. if [ -e wp-config.php ] ; then
  46.  
  47. 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`;
  48. mysqldump -u $user -p $db --password=$pass > backup/database-bk.sql
  49. echo "Your database has been saved to backup/database-bk.sql"
  50. fi
  51.  
  52. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement