Search code examples
linuxwordpressterminalcentosupdates

Update the plugin if it is already on the site


I have update plugin wordpress

And i want copy this update plugin folder to all website installed this plugin already before

like that:

if fastwpnow exist on /home/USERCLIENT/publich_html/wp-content/plugins/fastwpnow/ 

rm rf /home/USERCLIENT/publich_html/wp-content/plugins/fastwpnow/*

cp -R /home/MyUser/publich_html/wp-content/plugins/fastwpnow/* /home/USERCLIENT/publich_html/wp-content/plugins/fastwpnow/ 

How i can do that by linux terminal [centos 7]


Solution

  • you can use the below bash script(tested on centos7)

    or you can follow the same on terminal:

    #!/usr/bin/bash
    
    function exec_main {
    
    dir_name='/home/USERCLIENT/publich_html/wp-content/plugins/fastwpnow'
    target_name='/home/MyUser/publich_html/wp-content/plugins/fastwpnow'
    
    if [ -d $dir_name ] && [ -d $target_name ]
    then
    
        rm -rvf $dir_name/*
        cp -Rv $target_name/* $dir_name
    
    else
        echo "Error..."
    fi
    
    }
    
    exec_main
    
    1. save the above code as move_extensions.sh

    then on terminal give permissions and execute:

    chmod +x move_extensions.sh
    
    ./move_extensions.sh