Mini Shell

Direktori : /proc/self/root/opt/sharedrads/oldrads/
Upload File :
Current File : //proc/self/root/opt/sharedrads/oldrads/check_wpcache

#!/bin/bash

#load functions + banners
if [ -f /opt/sharedrads/radsfunctions.sh ]; then
    source /opt/sharedrads/radsfunctions.sh
else
    source /opt/dedrads/radsfunctions.sh
fi

echo

if [ "$RADSCOLORS" == "off" ];
then
        radsbanner-nocolor
else
       	radsbanner
fi

echo "  Not going anywhere for awhile?  Grab a snickers, and come back to this terminal in a few minutes."

# Find top 30 users based on sa stats
/usr/sbin/sa -cm | egrep -v 'root|nobody|mysql|nagios|mailnull|cpanel|100.00%' | head -50 | awk '{print $1}' > /tmp/.wpuserlist

if [ -f /tmp/.wpusers ]; then
rm -f /tmp/.wpusers
fi

# Find users running wordpress
echo
echo -n "Scanning for uncached wordpress installations"
for user in `cat /tmp/.wpuserlist`
do find /home/$user/public_html -type f -name wp-config.php >> /tmp/.wpusers
echo -n "."
done

echo
echo

# Build path's to search
for build in `cat /tmp/.wpusers`
do dirname $build >> /tmp/.wpsearchpath
done

touch /tmp/.needscache /tmp/.htachk

# Check if .htaccess exists
for chkht in `cat /tmp/.wpsearchpath`
do
if [ -f $chkht/.htaccess ]
then
# Search .htaccess for supercache string
username=$(echo $chkht | cut -d / -f3)
echo $username - `grep -i "begin wpsupercache" $chkht/.htaccess` >> /tmp/.htachk
else
echo $username - needs caching >> /tmp/.needscache
fi
done

# Compile list of users for notification of caching needed

cat /tmp/.htachk | grep -vi supercache | awk '{print $1}' | uniq > /tmp/.wpcleanup
cat /tmp/.needscache | awk '{print $1}' | uniq >> /tmp/.wpcleanup

echo "----------------------------------"
echo "Detected the following users with "
echo "uncached wordpress installations: "
echo "----------------------------------"

cat /tmp/.wpcleanup | sort | uniq

rm -f /tmp/.htachk /tmp/.needscache /tmp/.wpcleanup /tmp/.wpsearchpath /tmp/.wpusers /tmp/.wpuserlist

echo

Zerion Mini Shell 1.0