Get the most out of your Centmin Mod LEMP stack
Become a Member

Insight Guide How to customise centmin.sh option 22 wordpress routines & keep changes?

Discussion in 'Centmin Mod Insights' started by eva2000, Mar 2, 2019.

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

    eva2000 Administrator Staff Member

    42,078
    9,497
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,613
    Local Time:
    3:08 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    By design in Centmin Mod 123.09beta01, when you update Centmin Mod code via cmupdate command, a git stash/refresh of the latest Centmin Mod code on github.com is pulled to /usr/local/src/centminmod/ directory. So if you happen to modify your centmin.sh menu option 22 wordpress routine code which is contained in /usr/local/src/centminmod/inc/wpsetup.inc include file, those changes are reset/wiped on cmupdate command.

    However, as a workaround for now, you can automatically put in place your custom changes to /usr/local/src/centminmod/inc/wpsetup.inc using a custom mycmupdate command file you create below:

    First, backup any changes and customisations you did to your existing /usr/local/src/centminmod/inc/wpsetup.inc if any.

    Second, do a cmupdate which will resetup/wipe /usr/local/src/centminmod/inc/wpsetup.inc
    Code (Text):
    cmupdate

    then make a copy of the latest /usr/local/src/centminmod/inc/wpsetup.inc include file as /usr/local/src/centminmod/inc/wpsetup-custom.inc
    Code (Text):
    \cp -f /usr/local/src/centminmod/inc/wpsetup.inc /usr/local/src/centminmod/inc/wpsetup-custom.inc

    make all your customisations in the copied include file at /usr/local/src/centminmod/inc/wpsetup-custom.inc bringing over any changes you backed up previously

    then override the default /usr/local/src/centminmod/inc/wpsetup.inc with yours /usr/local/src/centminmod/inc/wpsetup-custom.inc
    Code (Text):
    \cp -f /usr/local/src/centminmod/inc/wpsetup-custom.inc /usr/local/src/centminmod/inc/wpsetup.inc

    now whenever you do cmupdate that will be overriden but you can then override it again with your /usr/local/src/centminmod/inc/wpsetup-custom.inc
    Code (Text):
    cmupdate
    \cp -f /usr/local/src/centminmod/inc/wpsetup-custom.inc /usr/local/src/centminmod/inc/wpsetup.inc
    

    then create your own cmupdate command as mycmupdate as cmupdate is just a symlink by creating file using touch command making it executable
    Code (Text):
    touch /usr/local/bin/mycmupdate
    chmod +x /usr/local/bin/mycmupdate
    

    then use vim/nano editors to edit /usr/local/bin/mycmupdate and just place in the following code
    Code (Text):
    #!/bin/bash
    cmupdate
    echo
    echo "diff"
    sdiff -s /usr/local/src/centminmod/inc/wpsetup.inc /usr/local/src/centminmod/inc/wpsetup-custom.inc
    echo
    \cp -f /usr/local/src/centminmod/inc/wpsetup-custom.inc /usr/local/src/centminmod/inc/wpsetup.inc
    echo "done"
    

    or if you prefer diff -u command instead of sdiff -s
    Code (Text):
    #!/bin/bash
    cmupdate
    echo
    echo "diff"
    diff -u /usr/local/src/centminmod/inc/wpsetup.inc /usr/local/src/centminmod/inc/wpsetup-custom.inc
    echo
    \cp -f /usr/local/src/centminmod/inc/wpsetup-custom.inc /usr/local/src/centminmod/inc/wpsetup.inc
    echo "done"
    

    it basically is a script to run cmupdate, then do a side by side comparison diff of original vs custom wpsetup-custom.inc files and then run copy command unaliased with forced override to use your custom version

    example run for mycmupdate command in SSH with sdiff -s
    Code (Text):
    mycmupdate                
    Saved working directory and index state WIP on 123.09beta01: ddf0302 update inc/php_configure.inc add znver2 target support for GCC 9 compiles in 123.09beta01
    HEAD is now at ddf0302 update inc/php_configure.inc add znver2 target support for GCC 9 compiles in 123.09beta01
    Already up-to-date.
    
    diff
      SALT=$(openssl rand 12 -base64 | tr -dc 'a-zA-Z0-9')        |   SALT=$(openssl rand 13 -base64 | tr -dc 'a-zA-Z0-9')
    }                                                             \ }
    
    done
    

    my custom copy i changed number of characters for database password SALT from 12 on left default wpsetup.inc to 13 characters o the right

    example run for mycmupdate command in SSH with diff -u
    Code (Text):
    mycmupdate                
    Saved working directory and index state WIP on 123.09beta01: ddf0302 update inc/php_configure.inc add znver2 target support for GCC 9 compiles in 123.09beta01
    HEAD is now at ddf0302 update inc/php_configure.inc add znver2 target support for GCC 9 compiles in 123.09beta01
    Already up-to-date.
    
    diff
    --- /usr/local/src/centminmod/inc/wpsetup.inc   2019-03-01 19:04:11.024346063 +0000
    +++ /usr/local/src/centminmod/inc/wpsetup-custom.inc    2019-03-01 18:58:40.601820797 +0000
    @@ -53,7 +53,7 @@
     }
    
     dbsetup() {
    -  SALT=$(openssl rand 12 -base64 | tr -dc 'a-zA-Z0-9')
    +  SALT=$(openssl rand 13 -base64 | tr -dc 'a-zA-Z0-9')
       DBN=$RANDOM
       DBNB=$RANDOM
       DBNC=$RANDOM
    @@ -2860,4 +2860,4 @@
    
     fi
    
    -}
    \ No newline at end of file
    +}
    
    done
    

    You can use the sdiff/diff to judge for yourself any changes in the latest default wpsetup.inc that need migrating over to your custom wpsetup-custom.inc manually after running mycmupdate
     
    • Like Like x 2
Thread Status:
Not open for further replies.