We can implement this by using jclouds scriptbuilder classes. For example, by putting bash functions in files named after the function in src/main/resources/functions we can call them with
It's also makes it possible for users to override the function by editing the file in functions, e.g. functions/function-name.sh, (since the CLI puts the top-level directory on the front of the classpath, so any functions defined here will take precedence to the ones in the JAR).
If we refactor the existing scripts to be functions like this, then we will no longer have to serve them from a webserver. However, for larger clusters it may be preferable to download files from a webserver, so that the client doesn't have to send a potentially large script to each node in the cluster. Instead it could upload the script to a blobstore, then send a runurl command to each node in the cluster (see https://github.com/jclouds/jclouds/raw/master/demos/test/ComputeAndBlobStoreTogetherHappilyLiveTest.java for one way of doing this). We could do this enhancement as a separate JIRA.
I've attached a patch which shows how this would look for an example script function. It runs a (possibly user-defined) script in the bootstrap phase of ZooKeeper.