#!/bin/bash #/ NAME #/ run-noop -- Run noop chef in separate workarea #/ #/ SYNOPSIS #/ #/ run-noop DIR VERSION DNA # figure out the project root under which bin, lib live shome="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)" # load a meat library source "$shome/libexec/_jason" "$@" DEFINE_boolean make "$FLAGS_FALSE" "Run make" # entry point function main { case "$#" in 0) logger_fatal "missing DIR VERSION DNA" exit 1 ;; 1) logger_fatal "missing VERSION DNA" exit 1 ;; 2) logger_fatal "missing DNA" exit 1 ;; 3) true ;; *) logger_fatal "too many args" exit 1 ;; esac local pth_workarea="$1"; shift local ver_repo="$1"; shift rm -f "$pth_workarea"/chef.{log,json} local pth_rna="rna/output/base.json" if [[ "$#" > 0 ]]; then pth_rna="$1"; shift fi if [[ ! -d "$pth_workarea/.git" ]]; then git clone . "$pth_workarea" FLAGS_make="$FLAGS_TRUE" fi cd "$pth_workarea" git fetch git fetch --tags git reset --hard "$ver_repo" if [[ "$FLAGS_make" = "$FLAGS_TRUE" ]]; then make fi bundle exec chef-local --noop -c etc/chef/solo.rb -j $pth_rna > "var/chef/reports/chef.log" (set +f; $shome/libexec/sanitize node "var/chef/reports/"chef*.json > "chef.json") $shome/libexec/sanitize log "var/chef/reports/chef.log" > "chef.log" } require sub "$BASH_SOURCE" "$@"