Sha256: 61a6136cee3729e8ff1caf445c8529dee41d1962404c7a0b7d29acbe31fff14c

Contents?: true

Size: 1.65 KB

Versions: 7

Compression:

Stored size: 1.65 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="$(ruby -ryaml -e 'puts YAML.load(File.read(ARGV[0]))[ARGV[1]]' $_AO_HOME/config/deploy.yml repository)"
  local git_spec="$(git_branch_head "$ver_repo")"

  local pth_rvmrun="${_AO_RUBY_LOADER:-}"
  : ${pth_rvmrun:=$(ruby -ryaml -e 'puts YAML.load(File.read(ARGV[0]))[ARGV[1]]' $_AO_HOME/config/deploy.yml ruby_loader)}
  local nm_ruby="$(ruby -ryaml -e 'puts YAML.load(File.read(ARGV[0]))[ARGV[1]]' $_AO_HOME/config/deploy.yml app_ruby)"

  local tmp_remote="$(ssh $hst_gateway mktemp -t XXXXXXXXX)"
  scp -q $shome/sbin/remote-helper $hst_gateway:$tmp_remote
  ssh -t $hst_gateway "$pth_rvmrun" "$nm_ruby" bash "$tmp_remote" "$USER" "$git_url" "$git_spec" "$@"
  ssh $hst_gateway rm -f $tmp_remote
}

require sub "$BASH_SOURCE" "$@"

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
alpha_omega-1.3.12 libexec/aoh-proxy
alpha_omega-1.3.11 libexec/aoh-proxy
alpha_omega-1.3.10 libexec/aoh-proxy
alpha_omega-1.4.1 libexec/aoh-proxy
alpha_omega-1.4.0 libexec/aoh-proxy
alpha_omega-1.3.9 libexec/aoh-proxy
alpha_omega-1.3.8 libexec/aoh-proxy