Sha256: 46dcbe61b86a8d68a8441595febc76920753559b4a76757e6124eba31661bdec

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

#!/bin/bash

#/ NAME
#/     proxy -- proxies deploy using a gateway host
#/
#/ SYNOPSIS
#/     
#/     proxy gateway version deploy_command args 
#/     proxy git_url git_spec gateway version deploy_command args 
#/

# figure out the project root under which bin, lib live
shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"

# load a jason bourne library
source "$shome/libexec/_treadstone"
get_started

function git_branch_head {
  local ver_repo="$1"; shift

  local git_branch=""
  local git_head="$ver_repo"
  if [[ "$ver_repo" = "HEAD" ]]; then
    git_branch="$(git symbolic-ref HEAD 2>&- | sed 's#^refs/heads/##' || true)"

    git_head="$(git rev-parse HEAD)"
    if [[ -z $git_head ]]; then
      echo "ERROR: could not find the SHA for HEAD" 1>&2
      return 1
    fi
  fi

  echo "$git_branch:$git_head"
}

# entry point
function main {
  local hst_gateway="$1"; shift
  local ver_repo="$1"; shift

  cd $_AO_HOME
  local git_url="$(ryaml $_AO_HOME/config/deploy.yml repository)"
  local git_spec="$(git_branch_head "$ver_repo")"

  local pth_rvmrun="${_AO_RUBY_LOADER:-}"
  : ${pth_rvmrun:=$(ryaml $_AO_HOME/config/deploy.yml ruby_loader)}
  local nm_ruby="$(ryaml $_AO_HOME/config/deploy.yml app_ruby)"

  local tmp_remote="$(ssh $hst_gateway mktemp -t XXXXXXXXX)"
  local bash_runner
  if [[ "${FLAGS_debug:-}" = 0 ]]; then
    set -x
    bash_runner="bash $tmp_remote --debug"
  else
    bash_runner="bash $tmp_remote"
  fi
  scp -q $shome/libexec/remote-helper $hst_gateway:$tmp_remote
  ssh -t $hst_gateway $bash_runner "${pth_rvmrun:-x}" "${nm_ruby:-x}" "$USER" "$git_url" "$git_spec" "$@"
  if [[ "${FLAGS_debug:-}" = 1 ]]; then
    ssh $hst_gateway rm -f $tmp_remote
  fi
}

require sub "$BASH_SOURCE" "$@"

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alpha_omega-1.5.3 libexec/aoh-proxy
alpha_omega-1.5.2 libexec/aoh-proxy
alpha_omega-1.5.1 libexec/aoh-proxy
alpha_omega-1.5.0 libexec/aoh-proxy