Guest User

Untitled

a guest
Nov 10th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ## You will need pwgen in order for this to work
  4.  
  5. type pwgen > /dev/null 2>&1 || { sudo yum install pwgen; exit 1; }
  6.  
  7. webrootdir=/home/admin/web/
  8. for domaindir in $(ls $webrootdir);
  9. do
  10. webdir="$webrootdir$domaindir/public_html";
  11. echo "#############";
  12. echo $webdir;
  13. echo "#############";
  14. cd $webdir;
  15. ls -lha;
  16. if $(wp core is-installed);
  17. then
  18. maindir="$webrootdir$domaindir";
  19. multisite=$(grep "'MULTISITE'" wp-config.php | cut -d',' -f2 | sed -r "s/[\'\)\;]+//g" | sed 's/\s//g');
  20. dbname=$(grep "DB_NAME" wp-config.php | cut -d',' -f2 | sed -r "s/['\)\;]+//g" | sed 's/\s//g');
  21. dbuser=$(grep "DB_USER" wp-config.php | cut -d',' -f2 | sed -r "s/[\'\)\;]+//g" | sed 's/\s//g');
  22. dbprefix=$(grep "\$table_prefix" wp-config.php | cut -d'=' -f2 | sed -r "s/[\'\)\;\"]+//g" | sed 's/\s//g');
  23. dbpass=$(pwgen -ysBv 12 1);
  24.  
  25.  
  26. echo "Database name: $dbname";
  27. echo "Database user: $dbuser";
  28. echo "Database password: $dbpass";
  29.  
  30. sudo /usr/local/vesta/bin/v-change-database-password admin $dbname $dbpass
  31.  
  32.  
  33. if [[ $multisite = "true" ]] ;
  34. then
  35. domain=$(grep "DOMAIN_CURRENT_SITE" wp-config.php | cut -d',' -f2 | sed -r "s/[\'\)\;]+//g" | sed 's/\s//g');
  36. fi
  37.  
  38. wp core verify-checksums
  39. mv wp-content/ ..;
  40. mv .user.ini ..;
  41. find "$maindir/wp-content/uploads/" -type f -name "*.php" -exec rm -rf {} \; -print;
  42. rm -rf "$maindir/wp-content/cache";
  43. rm -rf *;
  44. rm -rf .*;
  45. wp core download;
  46. rm -rf wp-content;
  47. mv $maindir/wp-content $webdir/;
  48. mv $maindir/.user.ini $webdir/;
  49. if [[ $multisite = "true" ]] ;
  50. then
  51. wp config create --dbprefix=$dbprefix --dbname=$dbname --dbuser=$dbuser --dbpass=$dbpass --force --extra-php << PHP
  52. define('WP_MEMORY_LIMIT', '256M');
  53. //define('WP_MAX_MEMORY_LIMIT', '256M');
  54. define( 'SUNRISE', 'on' );
  55. define( 'WP_ALLOW_MULTISITE', true );
  56. define( 'MULTISITE', true );
  57. define( 'SUBDOMAIN_INSTALL', false );
  58. define( 'DOMAIN_CURRENT_SITE', '$domain' );
  59. define( 'PATH_CURRENT_SITE', '/' );
  60. define( 'SITE_ID_CURRENT_SITE', 1 );
  61. define( 'BLOG_ID_CURRENT_SITE', 1 );
  62. PHP
  63. else
  64. wp config create --dbprefix=$dbprefix --dbname=$dbname --dbuser=$dbuser --dbpass=$dbpass --force --extra-php << PHP
  65. define('WP_MEMORY_LIMIT', '128M');
  66. //define('WP_MAX_MEMORY_LIMIT', '256M');
  67. PHP
  68. fi
  69. wp theme install $(wp theme list --field=name) --force;
  70. wp tgmpa-plugin install --all --force
  71. wp plugin install $(wp plugin list --field=name) --force;
  72. wp plugin update-all;
  73. wp theme update-all;
  74. # /home/admin/php-malware-finder/php-malware-finder/phpmalwarefinder -t 2 -v -l php $webdir
  75.  
  76. wp user list
  77. fi
  78. done
Add Comment
Please, Sign In to add comment