WPCloudDeploy Documentation

Filter Hook: wpcd_script_file_contents

apply_filters( 'wpcd_script_file_contents', $script_name )

This filter hook can be used to do two things:

  1. Change the contents of the wrapper commands sent to a server
  2. Change the script that a server will load to do a certain task.

The wrapper command scripts look similar to this:

sudo -i -E cd /root &&
sudo -E \rm -f ##SCRIPT_NAME## &&
sudo -E wget --no-check-certificate -O ##SCRIPT_NAME## ##SCRIPT_URL## &&
export action=##ACTION## domain=##DOMAIN## user=##BASIC_AUTH_USER## pass=##BASIC_AUTH_PASS## &&
sudo -E dos2unix ##SCRIPT_NAME## &&
sudo -E bash ##SCRIPT_NAME##

You can use this filter to point to a file in a different folder that contains a variant of this script.  For example, you can add additional commands to be executed after ##SCRIPT_NAME## executes on the server.

sudo -i -E cd /root &&
sudo -E \rm -f ##SCRIPT_NAME## &&
sudo -E wget --no-check-certificate -O ##SCRIPT_NAME## ##SCRIPT_URL## &&
export action=##ACTION## domain=##DOMAIN## user=##BASIC_AUTH_USER## pass=##BASIC_AUTH_PASS## &&
sudo -E dos2unix ##SCRIPT_NAME## &&
sudo -E bash ##SCRIPT_NAME##
sudo -E mycustomcommand

About ##SCRIPT_URL##

##SCRIPT_URL## is the pointer to the file that does all the real work on the server.   When you ask for WordPress to be installed, the filename pointed to by ##SCRIPT_URL## is loaded up from the server where WPCD is running to the server where WordPress needs to be installed.

To override this you can replace ##SCRIPT_URL## with a hard-coded pointer to your own version of the same file.

For example, you can hardcode ##SCRIPT_URL## to something like /html/mywpcdserver/custom_file.txt so that your script is the one that is always executing instead of our script.  The only restriction is that your custom_file.txt must have .txt extension AND it must be accessible via a remote wget() command.

sudo -i -E cd /root &&
sudo -E \rm -f ##SCRIPT_NAME## &&
sudo -E wget --no-check-certificate -O ##SCRIPT_NAME## /html/mywpcdserver/custom_file.txt &&
export action=##ACTION## domain=##DOMAIN## user=##BASIC_AUTH_USER## pass=##BASIC_AUTH_PASS## &&
sudo -E dos2unix ##SCRIPT_NAME## &&
sudo -E bash ##SCRIPT_NAME##

 

Share: