Last active
December 28, 2020 08:29
-
-
Save sajdoko/c5b491ab8428581d4533d59d0bf1f0d4 to your computer and use it in GitHub Desktop.
Bash script to update WordPress Plugins on a server managed with WHM/cPanel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# $1 group (premium||free) | |
# $2 plugin slug (all||single-name) | |
if [ "$1" == "premium" ] ; then | |
if [ "$2" == "all" ] || [ "$2" == "js_composer" ] ; then | |
if curl -o js_composer.zip https://serverlocalweb.com/js_composer.zip ; then | |
shkarkova_js_composer="1" | |
fi | |
fi | |
if [ "$2" == "all" ] || [ "$2" == "js_composer_theme" ] ; then | |
if curl -o js_composer_theme.zip https://serverlocalweb.com/js_composer_theme.zip ; then | |
shkarkova_js_composer_theme="1" | |
fi | |
fi | |
if [ "$2" == "all" ] || [ "$2" == "Ultimate_VC_Addons" ] ; then | |
if curl -o Ultimate_VC_Addons.zip https://serverlocalweb.com/Ultimate_VC_Addons.zip ; then | |
shkarkova_Ultimate_VC_Addons="1" | |
fi | |
fi | |
if [ "$2" == "all" ] || [ "$2" == "revslider" ] ; then | |
if curl -o revslider.zip https://serverlocalweb.com/revslider.zip ; then | |
shkarkova_revslider="1" | |
fi | |
fi | |
if [ "$2" == "all" ] || [ "$2" == "LayerSlider" ] ; then | |
if curl -o LayerSlider.zip https://serverlocalweb.com/LayerSlider.zip ; then | |
shkarkova_LayerSlider="1" | |
fi | |
fi | |
if [ "$2" == "all" ] || [ "$2" == "masterslider" ] ; then | |
if curl -o masterslider.zip https://serverlocalweb.com/masterslider.zip ; then | |
shkarkova_masterslider="1" | |
fi | |
fi | |
elif [ "$1" == "free" ] ; then | |
if [ "$2" == "all" ] || [ "$2" == "mainwp-child" ] ; then | |
if curl -o mainwp-child.zip https://serverlocalweb.com/mainwp-child.zip ; then | |
shkarkova_mainwp_child="1" | |
fi | |
fi | |
if [ "$2" == "all" ] || [ "$2" == "lw-all-in-one" ] ; then | |
if curl -o lw-all-in-one.zip https://serverlocalweb.com/lw-all-in-one.zip ; then | |
shkarkova_lw_all_in_one="1" | |
fi | |
fi | |
if [ "$2" == "all" ] || [ "$2" == "wp-fastest-cache-premium" ] ; then | |
if curl -o wp-fastest-cache-premium.zip https://serverlocalweb.com/wp-fastest-cache-premium.zip ; then | |
shkarkova_fastest_cache="1" | |
fi | |
fi | |
fi | |
function update_plugin { | |
# $1 found path | |
# $2 plugin directory | |
dir1=$( dirname "$1" ) | |
dir2=$( dirname "$dir1" ) | |
dir3=$( dirname "$dir2" ) | |
cp $2.zip $1/$2.zip | |
unzip -o $2.zip -d $1 > /dev/null | |
rm $1/$2.zip | |
user_name=$( basename "$dir3" ) | |
chown -R $user_name:$user_name $1/$2 | |
echo "bera update $1/$2 me username $user_name" | |
} | |
for f in $(find /home -maxdepth 4 -path "*/public_html/wp-content/plugins" -type d); | |
do | |
if [ "$1" == "premium" ] ; then | |
if [ -d "$f/js_composer" ] ; then | |
if [ "$shkarkova_js_composer" == "1" ] ; then | |
update_plugin $f js_composer | |
fi | |
fi | |
if [ -d "$f/js_composer_theme" ] ; then | |
if [ "$shkarkova_js_composer_theme" == "1" ] ; then | |
update_plugin $f js_composer_theme | |
fi | |
fi | |
if [ -d "$f/Ultimate_VC_Addons" ] ; then | |
if [ "$shkarkova_Ultimate_VC_Addons" == "1" ] ; then | |
update_plugin $f Ultimate_VC_Addons | |
fi | |
fi | |
if [ -d "$f/revslider" ] ; then | |
if [ "$shkarkova_revslider" == "1" ] ; then | |
update_plugin $f revslider | |
fi | |
fi | |
if [ -d "$f/LayerSlider" ] ; then | |
if [ "$shkarkova_LayerSlider" == "1" ] ; then | |
update_plugin $f LayerSlider | |
fi | |
fi | |
if [ -d "$f/masterslider" ] ; then | |
if [ "$shkarkova_masterslider" == "1" ] ; then | |
update_plugin $f masterslider | |
fi | |
fi | |
elif [ "$1" == "free" ] ; then | |
if [ -d "$f/mainwp-child" ] ; then | |
if [ "$shkarkova_mainwp_child" == "1" ] ; then | |
update_plugin $f mainwp-child | |
fi | |
fi | |
if [ -d "$f/lw-all-in-one" ] ; then | |
if [ "$shkarkova_lw_all_in_one" == "1" ] ; then | |
update_plugin $f lw-all-in-one | |
fi | |
fi | |
if [ -d "$f/wp-fastest-cache-premium" ] ; then | |
if [ "$shkarkova_fastest_cache" == "1" ] ; then | |
update_plugin $f wp-fastest-cache-premium | |
fi | |
fi | |
fi | |
done | |
if [ "$1" == "premium" ] ; then | |
if [ -f "js_composer.zip" ] ; then | |
rm js_composer.zip | |
fi | |
if [ -f "js_composer_theme.zip" ] ; then | |
rm js_composer_theme.zip | |
fi | |
if [ -f "Ultimate_VC_Addons.zip" ] ; then | |
rm Ultimate_VC_Addons.zip | |
fi | |
if [ -f "revslider.zip" ] ; then | |
rm revslider.zip | |
fi | |
if [ -f "LayerSlider.zip" ] ; then | |
rm LayerSlider.zip | |
fi | |
if [ -f "masterslider.zip" ] ; then | |
rm masterslider.zip | |
fi | |
elif [ "$1" == "free" ] ; then | |
if [ -f "mainwp-child.zip" ] ; then | |
rm mainwp-child.zip | |
fi | |
if [ -f "lw-all-in-one.zip" ] ; then | |
rm lw-all-in-one.zip | |
fi | |
if [ -f "wp-fastest-cache-premium.zip" ] ; then | |
rm wp-fastest-cache-premium.zip | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment