Learn about Centmin Mod LEMP Stack today
Register Now

Beta Branch tools/wpsiteinfo.sh wordpress tools for 123.09beta01

Discussion in 'Beta release code' started by eva2000, Jul 14, 2016.

Thread Status:
Not open for further replies.
  1. eva2000

    eva2000 Administrator Staff Member

    30,966
    6,919
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,422
    Local Time:
    4:34 AM
    Nginx 1.13.x
    MariaDB 5.5
    Another Centmin Mod tool i am working on is tools/wpsiteinfo.sh which is meant to allow you to
    1. Get a specific nginx domain's wordpress information
    2. Find all wordpress installs on server and get their respective wordpress information
    3. Check the wordpress version number for wordpress core and wp plugins for each respective wordpress install
    4. Send email and/or pushover push notifications to mobile and tablet devices when wordpress has a version or plugin update. The idea would be to offer something similar to tools/autoprotect.sh to automatically notify and/or update insecure wordpress installs regardless of whether the wordpress instance was installed via centmin.sh menu option 22 or if you manually installed wordpress. As it operates outside of wordpress itself, it will work more reliably and unattended without needing to log into wordpress itself.
    All tools/wpsiteinfo.sh usage command options
    Code (Text):
    ./wpsiteinfo.sh
    
    wpsiteinfo.sh {info|mask|find}
    
    Usage Commands:
    
    wpsiteinfo.sh info
    wpsiteinfo.sh info domain.com
    wpsiteinfo.sh mask
    wpsiteinfo.sh mask domain.com
    wpsiteinfo.sh find

    • First command option = info gets all info for a specific wordpress domain on server.
    • Second command option = mask does the same thing just masks the domain name and db name so you can post info publicly.
    • Both info and mask options have 2 modes of operation - interactive and unattended (when you pass the domain name on command line)
    • Third command option = find tries to find all wordpress installs on server and gets their respective info
    • TBD - not yet added check & notifications for wordpress core and plugin version updates

    Info command



    Code (Text):
    ./wpsiteinfo.sh info

    Code (Text):
    ./wpsiteinfo.sh info
    -----------------------------------------------------------------
    enter domain name of WordPress install: domain.com
    
    -----------------------------------------------------------------
    Getting WordPress Site Info
    -----------------------------------------------------------------
    
    WordPress version: 4.5.3
    Database revision: 36686
    TinyMCE version:   4.310 (4310-20160418)
    Success: WordPress is at the latest version.
    
    WordPress Domain: domain.com
    WordPress Install Dir: domain.com
    WordPress Local Install Dir: /home/nginx/domains/domain.com/public
    WordPress Database Name: wp27236db_15357
    WordPress Database home option: http://domain.com
    WordPress Database siteurl option: http://domain.com
    
    -----------------------------------------------------------------
    WordPress Plugin List Active:
    +-----------------+--------+-----------+---------+
    | name            | status | update    | version |
    +-----------------+--------+-----------+---------+
    | cache-enabler   | active | none      | 1.1.0   |
    | cdn-enabler     | active | none      | 1.0.3   |
    | disable-xml-rpc | active | none      | 1.0.1   |
    | optimus         | active | none      | 1.4.6   |
    | sucuri-scanner  | active | available | 1.8.0   |
    +-----------------+--------+-----------+---------+
    
    -----------------------------------------------------------------
    WordPress Plugin List In-Active:
    +---------------------------------+----------+--------+---------+
    | name                            | status   | update | version |
    +---------------------------------+----------+--------+---------+
    | akismet                         | inactive | none   | 3.1.11  |
    | wp-super-cache                  | inactive | none   | 1.4.8   |
    | wp-super-cache-clear-cache-menu | inactive | none   | 1.3.1   |
    +---------------------------------+----------+--------+---------+
    
    -----------------------------------------------------------------
    WordPress Theme List:
    +----------------+----------+--------+---------+
    | name           | status   | update | version |
    +----------------+----------+--------+---------+
    | twentyfifteen  | inactive | none   | 1.5     |
    | twentyfourteen | inactive | none   | 1.7     |
    | twentysixteen  | active   | none   | 1.2     |
    +----------------+----------+--------+---------+
    -----------------------------------------------------------------
    

    Unattended mode



    Code (Text):
    ./wpsiteinfo.sh info domain.com

    Code (Text):
    ./wpsiteinfo.sh info domain.com
    -----------------------------------------------------------------
    Getting WordPress Site Info
    -----------------------------------------------------------------
    
    WordPress version: 4.5.3
    Database revision: 36686
    TinyMCE version:   4.310 (4310-20160418)
    Success: WordPress is at the latest version.
    
    WordPress Domain: domain.com
    WordPress Install Dir: domain.com
    WordPress Local Install Dir: /home/nginx/domains/domain.com/public
    WordPress Database Name: wp27236db_15357
    WordPress Database home option: http://domain.com
    WordPress Database siteurl option: http://domain.com
    
    -----------------------------------------------------------------
    WordPress Plugin List Active:
    +-----------------+--------+-----------+---------+
    | name            | status | update    | version |
    +-----------------+--------+-----------+---------+
    | cache-enabler   | active | none      | 1.1.0   |
    | cdn-enabler     | active | none      | 1.0.3   |
    | disable-xml-rpc | active | none      | 1.0.1   |
    | optimus         | active | none      | 1.4.6   |
    | sucuri-scanner  | active | available | 1.8.0   |
    +-----------------+--------+-----------+---------+
    
    -----------------------------------------------------------------
    WordPress Plugin List In-Active:
    +---------------------------------+----------+--------+---------+
    | name                            | status   | update | version |
    +---------------------------------+----------+--------+---------+
    | akismet                         | inactive | none   | 3.1.11  |
    | wp-super-cache                  | inactive | none   | 1.4.8   |
    | wp-super-cache-clear-cache-menu | inactive | none   | 1.3.1   |
    +---------------------------------+----------+--------+---------+
    
    -----------------------------------------------------------------
    WordPress Theme List:
    +----------------+----------+--------+---------+
    | name           | status   | update | version |
    +----------------+----------+--------+---------+
    | twentyfifteen  | inactive | none   | 1.5     |
    | twentyfourteen | inactive | none   | 1.7     |
    | twentysixteen  | active   | none   | 1.2     |
    +----------------+----------+--------+---------+
    -----------------------------------------------------------------
    

    Find command



    Code (Text):
    ./wpsiteinfo.sh find

    Code (Text):
    ./wpsiteinfo.sh find
    -----------------------------------------------------------------
    Find All Wordpress Installs
    -----------------------------------------------------------------
    -----------------------------------------------------------------
    Found WordPress installed on:  domain1.com
    WordPress version: 4.5.3
    Database revision: 36686
    TinyMCE version:   4.310 (4310-20160418)
    Success: WordPress is at the latest version.
    wp db name:                    wp30468db_5059
    wp db home option:             http://domain1.com
    wp db siteurl option:          http://domain1.com
    install path: /home/nginx/domains/domain1.com/public
    config path: /home/nginx/domains/domain1.com/public/wp-config.php
    -----------------------------------------------------------------
    -----------------------------------------------------------------
    Found WordPress installed on:  domain.com
    WordPress version: 4.5.3
    Database revision: 36686
    TinyMCE version:   4.310 (4310-20160418)
    Success: WordPress is at the latest version.
    wp db name:                    wp27236db_15357
    wp db home option:             http://domain.com
    wp db siteurl option:          http://domain.com
    install path: /home/nginx/domains/domain.com/public
    config path: /home/nginx/domains/domain.com/public/wp-config.php
    -----------------------------------------------------------------
    


    Centmin Mod centmin.sh menu option 22 wordpress installer, already sets up a cronjob for auto updating wordpress plugins (and optionally wordpress core).
    Code (Text):
    crontab -l | grep wp_updater
    0 */8 * * * sleep 266s ;/root/tools/wp_updater_domain.com.sh 2>/dev/null
    0 */8 * * * sleep 100s ;/root/tools/wp_updater_domain1.com.sh 2>/dev/null
    

    Example for /root/tools/wp_updater_domain.com.sh which auto emails to email@domain.com
    Code (Text):
    #!/bin/bash
    PATH=/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/bin
    EMAIL=email@domain.com
    
    {
    cd /home/nginx/domains/domain.com/public
    echo "/home/nginx/domains/domain.com/public"
    #/usr/bin/wp cli update --allow-root
    echo "update wp-cli"
    rm -rf /usr/bin/wp
    wget -cnv --no-check-certificate https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/bin/wp --tries=3
    chmod 0700 /usr/bin/wp
    /usr/bin/wp --info --allow-root
    /usr/bin/wp plugin status --allow-root
    /usr/bin/wp plugin update --all --allow-root
    #/usr/bin/wp core check-update --allow-root
    #/usr/bin/wp core update --allow-root
    #/usr/bin/wp core update-db --allow-root
    chown -R nginx:nginx /home/nginx/domains/domain.com/public
    /usr/bin/nprestart
    } 2>&1 | /usr/bin/tr -cd '\11\12\15\40-\176' | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | dos2unix | mail -r $EMAIL -s "Wordpress WP-CLI Auto Update $(date)" $EMAIL
    

    To enable auto wp core updates, uncomment these 3 lines by removing hash # from front of the 3 lines
    Code (Text):
    #/usr/bin/wp core check-update --allow-root
    #/usr/bin/wp core update --allow-root
    #/usr/bin/wp core update-db --allow-root
    

     
    • Like Like x 2
Thread Status:
Not open for further replies.