#!/bin/sh # REQUIREMENTS: wp-cli wrapper and locate DB # get all path's with wp-config.php inside and filter only one in home folder if [ ! "$ALL_SITE_PATHS" ]; then ALL_SITE_PATHS=`locate /wp-config.php | grep -e '^/home/'` fi # process every single path for WP_SITE_PATH in $ALL_SITE_PATHS; do # extract username and WP dir path WP_USER_ACCOUNT=`echo $WP_SITE_PATH | sed -e 's/^\/home\///' | sed -e 's/\/public_html\/.*$//g'` WP_SITE_PATH_DIR=`echo $WP_SITE_PATH | sed -e 's/wp-config.php//g'` # this is command to run to get URL WP_URL=`sudo -u $WP_USER_ACCOUNT -- wp --path=$WP_SITE_PATH_DIR option get siteurl` WP_NAME=`sudo -u $WP_USER_ACCOUNT -- wp --path=$WP_SITE_PATH_DIR option get blogname` # now output info echo "$WP_SITE_PATH_DIR | $WP_URL | $WP_NAME" done
Comments