Skip to content
colinmollenhour edited this page Nov 16, 2012 · 2 revisions

Running shell commands on update

Modman allows any update, deploy, checkout or clone action to invoke shell commands defined in the modman file with the @shell operator. Two environment variables are exported before the command is run:

  • PROJECT - path to project root
  • MODULE - path to module root

Here is an example modman file with some shell commands:

# Deploy some modules
@import  modules/My_Module
@import  modules/Your_Module

# Clear the cache
@shell   rm -rf $PROJECT/var/cache/* && echo "Cache cleared"

The shell command will run with every update, not just the first. As such it could also be used to copy files to a location within the root if for some reason symlinks did not get the job done:

# These files don't like to be symlinked
@shell   if ! [ -d $PROJECT/lib/blah ]; then \
            cp -rf $MODULE/lib/blah $PROJECT/lib/blah \
         fi

As you see in the above example, line continuations are supported for multi-line commands.