Advertisement
urosevic

Get WP sites on server

Feb 4th, 2015
287
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # REQUIREMENTS: wp-cli wrapper and locate DB
  4.  
  5. # get all path's with wp-config.php inside and filter only one in home folder
  6. if [ ! "$ALL_SITE_PATHS" ]; then
  7.     ALL_SITE_PATHS=`locate /wp-config.php | grep -e '^/home/'`
  8. fi
  9.  
  10. # process every single path
  11. for WP_SITE_PATH in $ALL_SITE_PATHS; do
  12.  
  13.     # extract username and WP dir path
  14.     WP_USER_ACCOUNT=`echo $WP_SITE_PATH | sed -e 's/^\/home\///' | sed -e 's/\/public_html\/.*$//g'`
  15.     WP_SITE_PATH_DIR=`echo $WP_SITE_PATH | sed -e 's/wp-config.php//g'`
  16.  
  17.     # this is command to run to get URL
  18.     WP_URL=`sudo -u $WP_USER_ACCOUNT -- wp --path=$WP_SITE_PATH_DIR option get siteurl`
  19.     WP_NAME=`sudo -u $WP_USER_ACCOUNT -- wp --path=$WP_SITE_PATH_DIR option get blogname`
  20.  
  21.     # now output info
  22.     echo "$WP_SITE_PATH_DIR | $WP_URL | $WP_NAME"
  23.  
  24. done
Advertisement
RAW Paste Data Copied
Advertisement