Skip to content

Instantly share code, notes, and snippets.

@burtlo
Created October 18, 2017 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burtlo/89dc7d025d1ab484c2468740aadbe87e to your computer and use it in GitHub Desktop.
Save burtlo/89dc7d025d1ab484c2468740aadbe87e to your computer and use it in GitHub Desktop.
A script to help run packages that are built within the Habitat Studio.
# run pkg_name HEAD
# run pkg_name HEAD~1
function run() {
local pkg_name=$1
local pkg_position=$2
local found_pkgs=( ./results/$HAB_ORIGIN-$pkg_name-*.hart )
local pkg_count=${#found_pkgs[@]}
declare -A indexed_pkgs
for i in ${!found_pkgs[@]}; do
((current_count=pkg_count-1-i))
if [ $current_count == 0 ] ; then
head_offset="HEAD"
else
head_offset="HEAD~$current_count"
fi
indexed_pkgs+=([$head_offset]=${found_pkgs[$i]})
done
local pkg_to_run=${indexed_pkgs[$pkg_position]}
if [ -z "$pkg_to_run" ] ; then
echo "Could not find a package at $pkg_position. There are $pkg_count total package(s)."
return
fi
echo "Running $pkg_to_run"
hab sup start $pkg_to_run
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment