Up until this feature was introduced in WPCD 4.16.2, you could only make use of your custom bash scripts either by:
With this feature you now have a third option for the most common use case – running commands at the end of the server provisioning and site provisioning processes.
There are two types of post-processing scripts.
These scripts are used for new sites and servers. Because these servers and sites do not yet exist, there’s no place ‘local’ to store them so we allow you to set them up remotely.
First you need a place where you can create a publicly accessible text file using a standard https url. For example, the RAW version of gists.
Create a file with the bash commands you need to run.
Then, set the link in the WPCLOUDDEPLOY → SETTINGS → APP:WORDPRESS → CUSTOM SCRIPTS tab.
You can create simple text files and make them available at a public link with bash commands.
For new servers, you can:
For new sites you can do the following:
Your scripts will have access to the full complement of variables – which means that there is a lot of you can do without having to customize WPCD code directly. The above are just some ideas.
Here is an example of a post-processing script you can use on a site to install two plugins from the wordpress.org plugin repository:
So, you have a situation where you need to access a private github repository or maybe you want to add your plugin license key to new site installs. Since you should not place private data into public scripts, you need to make use of a secrets manager. The one we’ve used is called doppler.com but you can use any you like, as long as the following two requirements are met:
You can enter your api token in the SECRETS MANAGER API KEY field (see image earlier in this document). Then, that value will be available in the bash environment variable: $secret_key_manager_api_key
With this key, you should then be able to pull in all your other keys directly from your secrets manager.
You can use a secret GIST for your post-processing scripts. There are two caveats to be aware of:
There are, of course some things to watch out for when using this feature:
From a security perspective, if your remote link is compromised, so will any new servers or sites you provision.
Additionally, this feature is only useful if you do not need to set state data using post-metas in the WPCD plugin. Scripts you run using this method have no way of writing data back to WPCD without a custom add-on.
Some operations allow you to create a script with a specific name in an existing site or server. When the operation is complete it will look for a script with a particular name and run it if it exists.
The list of operations and the expected script name are as follows:
The post-processing script for cloning is especially useful when cloning ‘template’ sites associated with Multi-tenancy or our WooCommerce Integration. Add the script to the root of your template site and it will be executed after the site is cloned.
Note: Local post-processing scripts are a new feature in WPCD 5.3.0
Need post-processing scripts for other functions? Let us know your use case and we’ll try out best to make it happen!