Welcome to Centmin Mod Community
Register Now

Beta Branch Cronjob Auto Updating Centmin Mod Code Guide

Discussion in 'Beta release code' started by eva2000, Jun 15, 2015.

  1. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Dedicated thread for discussing how to auto update Centmin Mod via git (source post).

    Update: Jan 2018

    Centmin Mod 123.09beta01 latest update added a new /usr/bin/cmupdate command which can be setup as a cronjob to auto update Centmin Mod code at /usr/local/src/centminmod.

    Setup cronjob to run every 6 hrs
    Code (Text):
    0 */6 * * * /usr/bin/cmupdate 2>/dev/null
    

    You can also manually run the script via SSH command line to update code
    Code (Text):
    cmupdate
    



    Update: August 30th, 2017

    Centmin Mod 123.09beta01 latest update added a new /usr/local/src/centminmod/updatecm.sh script which can be setup as a cronjob to auto update Centmin Mod code at /usr/local/src/centminmod.

    Setup cronjob to run every 6 hrs
    Code (Text):
    0 */6 * * * /usr/local/src/centminmod/updatecm.sh 2>/dev/null
    

    You can also manually run the script via SSH command line to update code
    Code (Text):
     /usr/local/src/centminmod/updatecm.sh
    

    example output
    Code (Text):
     /usr/local/src/centminmod/updatecm.sh
    
    -------------------------------------
    Updating Centmin Mod code
    -------------------------------------
    
    * 123.09beta01
    No local changes to save
    Already up-to-date.
    commit 186f052622ced2970bd5a2537fc72d6dc00b4da7
    Author: George Liu <snipped>
    Date:   Wed Aug 30 08:45:13 2017 +1000
    
        chmod +x updatecm.sh
    
    -------------------------------------
    Updated Centmin Mod code
    -------------------------------------
    



    Updated: Feb 8th, 2016

    FYI, 1st post guide to auto updating centmin mod code via git environment setup is still valid for both Centmin Mod 123.08stable and 123.09beta01 and higher. Just the branchname differs for bash scripts and /usr/local/src/centminmod-${branchname} is now just /usr/local/src/centminmod

    for 123.08stable
    Code:
    #!/bin/bash
    branchname=123.08stable
    cd /usr/local/src/centminmod
    git stash
    git pull
    git log -1
    for 123.09beta01
    Code:
    #!/bin/bash
    branchname=123.09beta01
    cd /usr/local/src/centminmod
    git stash
    git pull
    git log -1
    With as many changes to Centmin Mod, some folks might want to use cronjob to auto update their Centmin Mod code. You can do this if you run centmin.sh menu option 23, submenu option 1 to setup git environment first.

    setup git environment via centmin.sh option 23, submenu 1
    Code:
    --------------------------------------------------------
    Centmin Mod 1.2.3-eva2000.08 - http://centminmod.com
    --------------------------------------------------------
                       Centmin Mod Menu    
    --------------------------------------------------------
    1).  Centmin Install
    2).  Add Nginx vhost domain
    3).  NSD setup domain name DNS
    4).  Nginx Upgrade / Downgrade
    5).  PHP Upgrade / Downgrade
    6).  XCache Re-install
    7).  APC Cache Re-install
    8).  XCache Install
    9).  APC Cache Install
    10). Memcached Server Re-install
    11). MariaDB 5.2, 5.5, 10, 10.1 Upgrade Sub-Menu
    12). Zend OpCache Install/Re-install
    13). Install ioping.sh vbtechsupport.com/1239/
    14). SELinux disable
    15). Install/Re-install ImageMagick PHP Extension
    16). Change SSHD Port Number
    17). Multi-thread compression: pigz,pbzip2,lbzip2,p7zip etc
    18). Suhosin PHP Extension install
    19). Install FFMPEG and FFMPEG PHP Extension
    20). NSD Re-install
    21). Update - Nginx + PHP-FPM + Siege
    22). Add Wordpress Nginx vhost + WP Super Cache
    23). Update Centmin Mod Code Base
    24). Exit
    --------------------------------------------------------
    Enter option [ 1 - 24 ] 23
    --------------------------------------------------------
    
    Code:
    --------------------------------------------------------
            Centmin Mod Updater Sub-Menu
    --------------------------------------------------------
    1). Setup Centmin Mod Github Environment
    2). Update Centmin Mod Current Branch
    3). Update Centmin Mod Newer Branch
    4). Back to Main menu
    --------------------------------------------------------
    Enter option [ 1 - 4 ] 1
    --------------------------------------------------------
    
    Code:
    setup Centmin Mod git sourced install...
    
    download github.com centmin mod 123.08beta03 branch repo
    Initialized empty Git repository in /usr/local/src/centminmod-123.08beta03/.git/
    Switched to a new branch '123.08beta03'
    Branch 123.08beta03 set up to track remote branch 123.08beta03 from origin.
    
    list all available local branches
            git branch -a
    * 123.08beta03
      master
      remotes/origin/123.06stable
      remotes/origin/123.07stable
      remotes/origin/123.08beta03
      remotes/origin/123.08beta03-libresslclang
      remotes/origin/123.08beta03-rtmp
      remotes/origin/123.08beta03clang
      remotes/origin/123.08beta03libressl
      remotes/origin/123.08centos7beta01
      remotes/origin/123.08centos7beta02
      remotes/origin/123.08zerodown
      remotes/origin/HEAD -> origin/master
      remotes/origin/master
    
    list git log last commit
            git log -a
    commit 29a67676c548e82b13079af0c10eebb220509b7c
    Author: George Liu <MAIL>
    Date:   Mon Jun 15 17:53:46 2015 +1000
    
        fix inc/openssl_install.inc for .08 beta 03 for LibreSSL make
    
    to update centmin mod 123.08beta03 branch repo via git
            cd /usr/local/src/centminmod-123.08beta03
            git stash
            git pull
            chmod +x centmin.sh
    now that you have git environment setup you can setup a cronjob every 6hrs to update your code

    create updatecm.sh i.e. at /root/tools/updatecm.sh (i usually place all my custom scripts in a directory i create at /root/tools)

    if using 123.08stable - 1.2.3-eva2000.08 then
    you'd have to adjust the path to /usr/local/src/centminmod
    Code:
    branchname=123.08stable
    cd /usr/local/src/centminmod
    so the file /root/tools/updatecm.sh's contents becomes
    Code:
    #!/bin/bash
    branchname=123.08stable
    cd /usr/local/src/centminmod
    git stash
    git pull
    git log -1
    chmod +x the /root/tools/updatecm.sh file
    Code:
    chmod +x /root/tools/updatecm.sh
    then setup cronjob every 6hrs using crontab -e command
    Code:
    0 */6 * * * /root/tools/updatecm.sh 2>/dev/null
    or
    setup cronjob every 2hrs using crontab -e command
    Code:
    0 */2 * * * /root/tools/updatecm.sh 2>/dev/null
    manually run script will also update the code and list the last commit made
    Code:
    /root/tools/updatecm.sh
    
    No local changes to save
    Already up-to-date.
    commit 29a67676c548e82b13079af0c10eebb220509b7c
    Author: George Liu <MAIL>
    Date:   Mon Jun 15 17:53:46 2015 +1000
    
        fix inc/openssl_install.inc for .08 beta 03 for LibreSSL make
     
    Last edited: Aug 30, 2017
  2. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+

    Persistent Custom centmin.sh Settings



    If you want to customise their centmin.sh options, you can override and keep persistent config changes which remain after Centmin Mod code changes/updates at ${CONFIGSCANBASE}/custom_config.inc which defaults to /etc/centminmod/custom_config.inc as outlined at CentOS 7.x - How to help test .08 CentOS 7 Betas with Github code ? | Page 22

    supports 2 locations for custom_config.inc
    1. inc/custom_config.inc where centmin.sh base directory resides
    2. at ${CONFIGSCANBASE}/custom_config.inc which defaults to /etc/centminmod/custom_config.inc
    to override centmin.sh settings and allow them to persist on centmin mod code updates, create a custom_config.inc at one of the 2 locations mentioned above and add the centmin.sh option to the custom_config.inc file i.e.

    to set PHP 5.6.8 + Zend Opcache as default place in manually created file at /etc/centminmod/custom_config.inc the following variables which are in centmin.sh to override centmin.sh ones
    Code:
    PHP_VERSION='5.6.8'
    ZOPCACHEDFT='y'
    
     
  3. Andy

    Andy Active Member

    540
    89
    28
    Aug 6, 2014
    Ratings:
    +132
    Local Time:
    10:46 PM
    Got some errors
    Code:
    [root@ethan centminmod-123.08beta03]# cronjob -e
    -bash: cronjob: command not found
    [root@ethan centminmod-123.08beta03]# sudo cronjob -e
    sudo: cronjob: command not found
    [root@ethan centminmod-123.08beta03]# /root/tools/updatecm.sh
    shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
    chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
    No local changes to save
    Already up-to-date.
    commit d62018cdf12aa1fb11da7bb2f2e41435710e93d7
    Author: George Liu <eva2000@centminmod.com>
    Date:   Sun Jun 21 22:20:59 2015 +1000
    
        update inc/nginx_addvhost.inc
     
  4. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    it's crontab -e for setting up cron job.. my bad :eek:

    also what's contents of /root/tools/updatecm.sh ?

    you'd have to adjust the path if it isn't at installed at /usr/local/src/centminmod-123.08beta03
    Code:
    branchname=123.08beta03
    cd /usr/local/src/centminmod-${branchname}
    if using 123.08stable - 1.2.3-eva2000.08 then
    you'd have to adjust the path to /usr/local/src/centminmod
    Code:
    branchname=123.08stable
    cd /usr/local/src/centminmod
     
    Last edited: Jul 29, 2015
  5. Andy

    Andy Active Member

    540
    89
    28
    Aug 6, 2014
    Ratings:
    +132
    Local Time:
    10:46 PM
    Probably should update this as well :)
     
  6. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  7. Andy

    Andy Active Member

    540
    89
    28
    Aug 6, 2014
    Ratings:
    +132
    Local Time:
    10:46 PM
    Shouldn't your cronjob schedule be
    0 */3 * * * /root/tools/updatecm.sh 2>/dev/null
    you had
    * */3 * * * /root/tools/updatecm.sh 2>/dev/null
    which will run every minutes of every 3 hour.
     
  8. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    doh ! nice catch (y) corrected 1st post :)
     
  9. Andy

    Andy Active Member

    540
    89
    28
    Aug 6, 2014
    Ratings:
    +132
    Local Time:
    10:46 PM
    Caused my 250GB server disk to be full this morning to catch this.
    I use similar syntax to do backup and it fill up quickly as you can imagine :)
     
  10. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    hehe.. although updatecm.sh would only overwrite existing data so shouldn't fill up that much i think or you mean your backup script filled it up ?
     
  11. Andy

    Andy Active Member

    540
    89
    28
    Aug 6, 2014
    Ratings:
    +132
    Local Time:
    10:46 PM
    Yeah, my backup filled it up with multiple copies of site files, each 5GB. :)
     
  12. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    lessened learned I guess :) thanks for catching that.. will go through centminmod.com site's posted info/instructions and see if have any boo boos like that too :)

    edit: ah i see the instruction was on Upgrade Centmin Mod - CentminMod.com LEMP Nginx web stack for CentOS - fixing it now :)
     
  13. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    FYI, 1st post guide to auto updating centmin mod code via git environment setup is still valid for both Centmin Mod 123.08stable and 123.09beta01 and higher. Just the branchname differs for bash scripts and /usr/local/src/centminmod-${branchname} is now just /usr/local/src/centminmod

    for 123.08stable
    Code:
    #!/bin/bash
    branchname=123.08stable
    cd /usr/local/src/centminmod
    git stash
    git pull
    git log -1
    for 123.09beta01
    Code:
    #!/bin/bash
    branchname=123.09beta01
    cd /usr/local/src/centminmod
    git stash
    git pull
    git log -1
     
  14. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    reminder folks can set the above script up to auto update the Centmin Mod code located at /usr/local/src/centminmod ;)

    It's what i do for 120+ servers :)
     
  15. RB1

    RB1 Active Member

    292
    75
    28
    Nov 11, 2016
    California
    Ratings:
    +122
    Local Time:
    8:46 PM
    Nginx 1.21.x
    MariaDB 10.1.x
    Great guide...just set my CCM install to update every 12 hours :)

    Tested via:
    /root/tools/updatecm.sh
    Seems to be working although I'm already on the latest git update. We'll see how it goes on the next update!
     
    Last edited: Jan 29, 2017
  16. RB1

    RB1 Active Member

    292
    75
    28
    Nov 11, 2016
    California
    Ratings:
    +122
    Local Time:
    8:46 PM
    Nginx 1.21.x
    MariaDB 10.1.x
    Just tested, auto-update works with no problems on my second CMM server (y)
     
  17. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    great to hear :)
     
  18. SFLC

    SFLC Active Member

    223
    59
    28
    Dec 4, 2016
    The Canadas
    Ratings:
    +112
    Local Time:
    5:46 AM
    1
    10
    for the autoupdate cron, could i add this into the custom_config.inc file for added security, my thinking is, let people think apache is there, but in reality, centminmod runs nginx :blackalien:, and yes i know this is a bit tin-foil-hat-ish

    CUSTOMSERVERNAME='y'
    CUSTOMSERVERSTRING='Apache'
     
  19. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    that no longer works in 123.09beta01
    Centmin Mod 123.08stable and higher sets Nginx server banner in /usr/local/nginx/conf/nginx.conf (can get to it via shortcut command = nginxconf which invokes nano text editor on /usr/local/nginx/conf/nginx.conf)
    Code (Text):
    more_set_headers "Server: nginx centminmod";
    more_set_headers "X-Powered-By: centminmod";
     
  20. eva2000

    eva2000 Administrator Staff Member

    53,533
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    1:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Centmin Mod 123.09beta01 latest update added a new /usr/local/src/centminmod/updatecm.sh script which can be setup as a cronjob to auto update Centmin Mod code at /usr/local/src/centminmod.

    Setup cronjob to run every 6 hrs
    Code (Text):
    0 */6 * * * /usr/local/src/centminmod/updatecm.sh 2>/dev/null
    

    You can also manually run the script via SSH command line to update code
    Code (Text):
     /usr/local/src/centminmod/updatecm.sh
    

    example output
    Code (Text):
     /usr/local/src/centminmod/updatecm.sh
    
    -------------------------------------
    Updating Centmin Mod code
    -------------------------------------
    
    * 123.09beta01
    No local changes to save
    Already up-to-date.
    commit 186f052622ced2970bd5a2537fc72d6dc00b4da7
    Author: George Liu <snipped>
    Date:   Wed Aug 30 08:45:13 2017 +1000
    
        chmod +x updatecm.sh
    
    -------------------------------------
    Updated Centmin Mod code
    -------------------------------------