Skip to content

Instantly share code, notes, and snippets.

@ahonor
Last active May 14, 2022 22:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahonor/f61569190327c16a293d to your computer and use it in GitHub Desktop.
Save ahonor/f61569190327c16a293d to your computer and use it in GitHub Desktop.
example wrapper for rerun modules
#!/usr/bin/env bash
# Wrapper for modules sharing same prefix
: ${RERUN:=$(which rerun)}
: ${RERUN_MODULE_PREFIX:=rundeck-}
if (( $# == 1 ))
then
exec command $RERUN ${RERUN_MODULE_PREFIX}${1}
elif (( $# >= 2 ))
then
mod=$1
shift
exec command $RERUN ${RERUN_MODULE_PREFIX}${mod}: "$@"
else
. $RERUN
for mod in $(rerun_modules $RERUN_MODULES)
do
regex="${RERUN_MODULE_PREFIX}([a-z]+)"
if [[ $mod =~ $regex ]]
then
echo ${BASH_REMATCH[1]}
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment