Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #usage ./update-plugin plugin-name pluginver
- function updateit {
- pluginpath=$1
- pluginname=$2
- user=$3
- pluginmain=${pluginpath%$pluginname}
- echo "Updating plugin for $user"
- $(rm -rf $pluginpath)
- $(cp -R /opt/$pluginname/ $pluginmain)
- $(chown -R $user:$user $pluginpath)
- $(find $pluginpath -type f -print0 | xargs -0 chmod 0644)
- $(find $pluginpath -type d -print0 | xargs -0 chmod 0755)
- }
- plugin=$1
- pluginver=$2
- usernames=$(find /var/cpanel/users -type f -print0 | xargs -n 1 -0 echo)
- prefix="/var/cpanel/users/"
- $(rm -rf /opt/"$plugin"*)
- #$(rm -rf /opt/$plugin.zip)
- $(wget -O /opt/$plugin.zip https://downloads.wordpress.org/plugin/$plugin.$pluginver.zip)
- $(unzip /opt/"$plugin".zip -d /opt)
- for i in $usernames; do
- username=${i#$prefix}
- path=$(find /home/$username -type d -name "$plugin")
- if echo $path | grep -E '[ "]' >/dev/null
- then
- for pp in $path; do
- updateit $pp $plugin $username
- done
- else
- if [[ $path = *[!\ ]* ]]; then
- updateit $path $plugin $username
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement