Skip to content

Instantly share code, notes, and snippets.

@naviat
Forked from tamirko/chmod.groovy
Created January 25, 2018 07:55
Show Gist options
  • Save naviat/9cc54845f0fc56656e68f7487cd835bd to your computer and use it in GitHub Desktop.
Save naviat/9cc54845f0fc56656e68f7487cd835bd to your computer and use it in GitHub Desktop.
change permissions example
/* Groovy Usage:
This code snippet changes the permissions
of all the files inside the /usr/bin/myapp/data folder.
In this case, all the files in /usr/bin/myapp/data
will be writable after invoking this command.
*/
builder = new AntBuilder()
builder.chmod(dir:"/usr/bin/myapp/data", perm:'+w', includes:"*")
/* Usage in Cloudify:
The following code snippet changes the permissions
of all the shell files in the service recipe folder.
In this case, all these *.sh files will be executable.
This code snippet also writes a (debug) message prior to invoking the chmod.
*/
context = ServiceContextFactory.getServiceContext()
builder = new AntBuilder()
builder.sequential {
echo(message:"apacheLB_install.groovy: Chmodding +x ${context.serviceDirectory} ...")
chmod(dir:"${context.serviceDirectory}", perm:"+x", includes:"*.sh")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment