Skip to content

Instantly share code, notes, and snippets.

@yogendra
Last active February 20, 2020 15:39
Show Gist options
  • Save yogendra/318c09f0cd2548bdd07f592722c9bbec to your computer and use it in GitHub Desktop.
Save yogendra/318c09f0cd2548bdd07f592722c9bbec to your computer and use it in GitHub Desktop.
PCF Tools (Jumpbox, k8s, direnv)

PCF Tools

  • Includes jumpbox initialization scripts
  • Direnv config
  • Tmux config
  • Vim setup

Quickstart

  • On VM
read -s -p "Enter Pivnet Legacy token (Not ending in '-r'): " OM_PIVNET_TOKEN
wget -qO- "https://gist.github.com/yogendra/318c09f0cd2548bdd07f592722c9bbec/raw/jumpbox-init.sh?nocache"  | bash
  • Using docker
# Run container
docker run --name pcf-jumpbox --hostname pcf-jumpbox -v $HOME/workspace:/home/pcf/workspace yogendra/pcf-jumpbox -d

# Connect to container
docker exec -it pcf-jumpbox bash
#-*- mode: sh; -*-
# This is a extra goodness for direnv
# adds
# use pcf-toolsmith <pcf-domain> <om-password>
# use pcf-pez <haas-id> <password>
# use pcf-terraform <domain> <om-password>
# use pcf [domain]
# use pcf-pas
# use pcf-pks
# To use just append content to your $HOME/.direnvrc. You may use following command to do same
use_python() {
if [ -n "$(which pyenv)" ]; then
local pyversion=$1
pyenv local ${pyversion}
fi
}
layout_virtualenv() {
local pyversion=$1
local pvenv=$2
if [ -n "$(which pyenv virtualenv)" ]; then
pyenv virtualenv --force --quiet ${pyversion} ${pvenv}-${pyversion}
fi
pyenv local --unset
}
layout_activate() {
if [ -n "$(which pyenv)" ]; then
source $HOME/.pyenv/versions/$1/bin/activate
fi
}
use_docker-machine(){
local env=${1:-default}
echo Docker machine: $env
local machine_cmd=$(docker-machine env --shell bash $env)
eval $(docker-machine env --shell bash $env)
export DOCKER_MACHINE_IP=$(docker-machine ip $env)
}
use_nvm() {
local node_version=$1
nvm_sh=~/.nvm/nvm.sh
if [[ -e $nvm_sh ]]; then
source $nvm_sh
nvm use $node_version
fi
}
export_function() {
local name=$1
local alias_dir=$PWD/.direnv/aliases
mkdir -p "$alias_dir"
PATH_add "$alias_dir"
local target="$alias_dir/$name"
if declare -f "$name" >/dev/null; then
echo "#!/usr/bin/env bash" > "$target"
declare -f "$name" >> "$target" 2>/dev/null
echo "$name \$*" >> "$target"
chmod +x "$target"
fi
}
use_pcf-terraform() {
DOMAIN=$1; shift
export PCF_DOMAIN=$DOMAIN
export OM_TARGET=pcf.$DOMAIN
export OM_USERNAME=admin
export OM_SKIP_SSL_VALIDATION=true
export OM_PASSWORD=$1; shift
export OM_DECRYPTION_PASSPHRASE=$OM_PASSWORD
export OM_KEY=${1:-om.key}
use pcf
}
use_pcf-toolsmith() {
export TS_G_ENV=$1
[[ -z $TS_G_ENV ]] && export TS_G_ENV=$(basename $PWD)
export ROOT_DOMAIN=cf-app.com
export PCF_ENV_FILE=$PWD/${TS_G_ENV}.json
watch_file $PCF_ENV_FILE
[[ ! -f $PCF_ENV_FILE ]] && export PCF_ENV_FILE=~/Downloads/${TS_G_ENV}.json
[[ ! -f $PCF_ENV_FILE ]] && echo environment file not found && exit 1
export OM_TARGET=$(jq -r .ops_manager_dns ${PCF_ENV_FILE})
export OM_USERNAME=$(jq -r .ops_manager.username ${PCF_ENV_FILE})
export OM_PASSWORD=$(jq -r .ops_manager.password ${PCF_ENV_FILE})
export OM_KEY=$PWD/opsman.key
export OM_SKIP_SSL_VALIDATION=true
export PCF_DOMAIN=$TS_G_ENV.$ROOT_DOMAIN
if [[ ! -f $OM_KEY ]]
then
echo Extracting Ops Man key
echo "$(jq -r .ops_manager_private_key < ${PCF_ENV_FILE})" > ${OM_KEY} && chmod 600 ${OM_KEY}
fi
use pcf
}
use_pcf-pez () {
# Required argumets:
# 1 - PEZ_HAAS_ID (Example: 207)
# 2 - PEZ_PASSWD (Example: kjshak734879fzsbSA)
# Example:
# use pez 207 80fsaufoasposduf9
export PEZ_HAAS_ID=$1
export PEZ_PASSWD=$2
export PEZ_NAME=haas-${PEZ_HAAS_ID}
export PEZ_DOMAIN=${PEZ_NAME}.pez.pivotal.io
export PEZ_JUMPBOX_WIN=jumpbox-${PEZ_HAAS_ID}.${PEZ_DOMAIN}
export PEZ_JUMPBOX_LINUX=ubuntu-${PEZ_HAAS_ID}.${PEZ_DOMAIN}
export PEZ_VCENTER=vcsa-01.${PEZ_DOMAIN}
export PEZ_NSXMGR=nsxmgr-01.${PEZ_DOMAIN}
export OM_TARGET=opsmgr-02.${PEZ_DOMAIN}
export OM_USERNAME=admin
export OM_PASSWORD="${PEZ_PASSWD}"
export OM_SKIP_SSL_VALIDATION=true
export OM_KEY=$PWD/$PEZ_NAME.key
export PCF_PKS_API=api.run.${PEZ_DOMAIN}
export PCF_DOMAIN=$PEZ_DOMAIN
function pcf-pez-ssh-jumpbox {
echo ssh \
-i $PWD/$PEZ_NAME.key \
-o PasswordAuthentication=no \
ubuntu@$PEZ_JUMPBOX_LINUX
}
export_function pcf-pez-ssh-jumpbox
use pcf
}
use_pcf() {
# Required Variables:
# OM_TARGET - OpsMan Address
# OM_USERNAME - OpsMan username
# OM_PASSWORD - OpsMan password
# OM_SKIP_SSL_VALIDATION - Skip OpsMan SSL checks
# OM_KEY - path to OpsMsn key
export UAAC_HOME=$PWD
export PCF_OPSMAN_KEYFILE=$OM_KEY
export OM_CA_CERTS=$PWD/opsman-ca-certs.pem
if [[ ! -f $OM_CA_CERTS ]]
then
echo Extracting Ops Manager ca certifiactes
om -k certificate-authorities --format json | jq -r '.[].cert_pem' > $OM_CA_CERTS
fi
if [ -z "$OM_TARGET" -o -z "$OM_USERNAME" -o -z "$OM_PASSWORD" -o -z "$OM_KEY" ]
then
echo "OM_TARGET, OM_USERNAME, OM_PASSWORD and OM_KEY are required to be set"
exit 1
fi
export PCF_DOMAIN=${1:-$PCF_DOMAIN}
[[ -z $PCF_DOMAIN ]] && echo "You need to provide pcf domain root or set PCF_DOMAIN variable" && exit 1
export PCF_BBR_KEYFILE=$PWD/bbr.key
export PCF_BOSH_CA_CERT=$PWD/bosh-ca.cer
export PCF_BOSH_ENV=$PWD/.env-bosh
export BOSH_ALL_PROXY="ssh+socks5://ubuntu@$OM_TARGET:22?private-key=$OM_KEY"
export BOSH_CA_CERT=$PCF_BOSH_CA_CERT
if [[ ! -f $PCF_BOSH_CA_CERT ]]
then
echo Extracting Bosh CA Cert
om --target https://$OM_TARGET --skip-ssl-validation --username $OM_USERNAME --password $OM_PASSWORD certificate-authorities -f json | jq -r '.[] | select(.active==true) | .cert_pem' > $PCF_BOSH_CA_CERT && chmod 600 ${PCF_BOSH_CA_CERT}
fi
if [[ ! -f $PCF_BBR_KEYFILE ]]
then
echo Extracting BBR Key
echo "$(om -k credentials --product-name p-bosh --credential-reference .director.bbr_ssh_credentials -f private_key_pem)" > ${PCF_BBR_KEYFILE} && chmod 600 ${PCF_BBR_KEYFILE}
fi
if [[ ! -f $PCF_BOSH_ENV ]]
then
CREDS=$(om -k curl --path /api/v0/deployed/director/credentials/bosh_commandline_credentials -s | jq .credential -r | sed -E 's/bosh//')
[ -n "${ZSH_VERSION}" ] && setopt shwordsplit
array=($CREDS)
for VAR in ${array[@]}; do
[[ ! $VAR =~ ^BOSH_CA_CERT= ]] && echo export $VAR >> $PCF_BOSH_ENV
done
[ -n "${ZSH_VERSION}" ] && unsetopt shwordsplit
fi
watch_file $PCF_BOSH_ENV
source $PCF_BOSH_ENV
function pcf-pcf-info {
echo OpsMan: https://${OM_TARGET}
}
export_function pcf-pcf-info
function pcf-info {
pcf-pcf-info
}
export_function pcf-info
function pcf-opsman {
echo $OM_PASSWORD | pbcopy
open https://$OM_TARGET
}
export_function pcf-opsman
function pcf-opsman-ssh {
ssh -i $PCF_OPSMAN_KEYFILE -o StrictHostKeyChecking=no ubuntu@$OM_TARGET $*
}
export_function pcf-opsman-ssh
}
use_pcf-pas() {
export CF_HOME=$PWD
export PCF_DOMAIN=${1:-$PCF_DOMAIN}
[[ -z $PCF_DOMAIN ]] && echo "You need to provide pcf domain root or set PCF_DOMAIN variable" && exit 1
export PCF_SYS_DOMAIN=sys.${PCF_DOMAIN}
export PCF_APP_DONAIN=apps.${PCF_DOMAIN}
export PCF_OPSMAN=pcf.${PCF_DOMAIN}
export PCF_PAS_APPSMAN=apps.${PCF_SYS_DOMAIN}
export PCF_PAS_API=api.${PCF_SYS_DOMAIN}
[[ ! -d $CF_HOME ]] && mkdir $CF_HOME
function pcf-info {
pcf-pcf-info
echo AppsMan: https://${PCF_PAS_APPSMAN}
echo PAS API: ${PCF_PAS_API}
echo CF_HOME=$CF_HOME
}
export_function pcf-info
function pcf-pas-login {
cf login --skip-ssl-validation -a https://${PCF_PAS_API} -u admin -p $(om credentials -p cf -c .uaa.admin_credentials -f password)
}
export_function pcf-pas-login
function pcf-pas-appsman {
open https://$PCF_PAS_APPSMAN
}
export_function pcf-pas-appsman
}
use_pcf-pks () {
export PCF_DOMAIN=${1:-$PCF_DOMAIN}
export KUBECONFIG=$PWD/.kubeconfig
export PCF_PKS_API_CA_CERT=$PWD/pks-api-ca.pem
export HELM_HOME=$PWD/.helm
export PKS_HOME=$PWD
[[ -z $PCF_DOMAIN ]] && echo "You need to provide pcf domain root or set PCF_DOMAIN variable" && exit 1
export PCF_PKS_API=${PCF_PKS_API:-api.pks.${PCF_DOMAIN}}
if [[ -n $PEZ_HAAS_ID ]]; then
export PCF_PKS_API=api.run.${PCF_DOMAIN}
fi
export PKS_API=$PCF_PKS_API
if [[ ! -f $PCF_PKS_API_CA_CERT ]]
then
echo Extracting PKS API CA Certificate
echo "$(om -k credentials --product-name pivotal-container-service --credential-reference .pivotal-container-service.pks_tls -f cert_pem)" > ${PCF_PKS_API_CA_CERT} && chmod 600 ${PCF_PKS_API_CA_CERT}
fi
function pcf-pks-uaac-target {
uaac target https://${PCF_PKS_API}:8443 --ca-cert $PCF_PKS_API_CA_CERT --skip-ssl-validation
}
export_function pcf-pks-uaac-target
function pcf-pks-uaac-login {
pcf-pks-uaac-target
uaac token client get admin -s $(om -k credentials --product-name pivotal-container-service --credential-reference .properties.pks_uaa_management_admin_client -f secret)
}
export_function pcf-pks-uaac-login
function pcf-pks-login {
pks login -k -a ${PCF_PKS_API} -u admin -p "$(om credentials -p pivotal-container-service --credential-reference .properties.uaa_admin_password -f secret)"
}
export_function pcf-pks-login
function pcf-info {
pcf-pcf-info
echo PKS API: ${PCF_PKS_API}
}
export_function pcf-info
function pcf-pks-create-cluster {
CLUSTER_ID=${1:-cluster-1}
CLUSTER_PLAN=${2:-small}
CLUSTER_NAME=${TS_G_ENV}-pks-${CLUSTER_ID}
CLUSTER_HOSTNAME=${CLUSTER_ID}.${PCF_DOMAIN}
pks create-cluster $CLUSTER_NAME --external-hostname ${CLUSTER_HOSTNAME} --plan $CLUSTER_PLAN && \
if ! nslookup $CLUSTER_HOSTNAME >> /dev/null
then
cat <<EOF
$CLUSTER_HOSTNAME: not found.
- You should configure it on the DNS
- On GCP use GCP Consol > Networking > Cloud DNS (https://console.cloud.google.com/net-services/dns/zones) to set correct IP
- On AWS [WIP]
- On Azure [WIP]
EOF
fi
}
export_function pcf-pks-create-cluster
}
#############################
########## Bindings
#############################
# Set the prefix to `ctrl + a` instead of `ctrl + b`
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
# Use | and - to split a window vertically and horizontally instead of " and % respoectively
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# Open ~/.tmux.conf in vim and reload settings on quit
unbind e
bind e new-window -n '~/.tmux.conf' "sh -c 'nvim ~/.tmux.conf && tmux source ~/.tmux.conf'"
# Bind D to resize the window to be 8 lines smaller
bind D resize-pane -D 8
# Move around panes with hjkl, as one would in vim after pressing ctrl + w
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Switch betewen panes using alt + arrow
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Use shift + arrow key to move between windows in a session
bind -n S-Left previous-window
bind -n S-Right next-window
# Use r to quickly reload tmux settings
unbind r
bind r \
source-file ~/.tmux.conf \;\
display 'Reloaded tmux config'
# Use m to toggle mouse mode
unbind m
bind m setw mouse
# Use a to toggle synchronize panes
bind a set-window-option synchronize-panes
# prefix + / to search
bind-key / copy-mode \; send-key ?
# prefix + h to clear screen and history buffer
bind y \
send-keys "C-c; clear && tmux clear-history" \;\
send-keys "Enter" \;\
display 'Screen cleared'
# Setup 'v' to begin selection, just like Vim
bind-key -T copy-mode-vi 'v' send -X begin-selection
# Setup 'y' to yank (copy), just like Vim
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi 'V' send -X select-line
bind-key -T copy-mode-vi 'r' send -X rectangle-toggle
#############################
########## Settings
#############################
# Refresh status line every 5 seconds - Good for when music is playing / update time etc
set -g status-interval 5
# Start window and pane indices at 1.
set -g base-index 1
set -g pane-base-index 1
# length of tmux status line
set -g status-left-length 30
set -g status-right-length 150
# Make active pane border blue
set -g pane-active-border-style fg=colour1
#Set the left and right status
set -g status-left '#[bg=colour7]#[fg=colour0]#{?client_prefix,#[bg=colour2],} ❐ #S #[bg=colour0]#[fg=colour7]#{?client_prefix,#[fg=colour2],}#{?window_zoomed_flag, 🔍 ,}#[fg=colour1] ♥ #(~/dotfiles/tmux_scripts/battery.sh) '
set -g status-right '#[fg=colour7]#[bg=colour7] #[fg=colour2]#(~/dotfiles/tmux_scripts/uptime.sh) #[fg=colour1]#[fg=colour3]#[bg=colour3]#[fg=colour0] #(~/dotfiles/tmux_scripts/music.sh) #[bg=colour3]#[fg=colour1]#[bg=colour1]#[fg=colour0] %b %d %H:%M '
# Set the background color
set -g status-bg colour0
# customize how windows are displayed in the status line
set -g window-status-current-format "#[fg=colour0]#[bg=colour4]#[fg=colour7]#[bg=colour4] #I* #[fg=colour7] #W #[fg=colour4]#[bg=colour0]"
set -g window-status-format "#[fg=colour244]#[bg=colour0]#I-#[fg=colour240]  #W"
# Set the history limit so we get lots of scrollback.
#setw -g history-limit 50000
#############################
############# Tmux Vars
#############################
# $(echo $USER) - shows the current username
# %a --> Day of week (Mon)
# %A --> Day of week Expanded (Monday)
# %b --> Month (Jan)
# %d --> Day (31)
# %Y --> Year (2017)
# %D --> Month/Day/Year (12/31/2017)
# %v --> Day-Month-Year (31-Dec-2017)
# %r --> Hour:Min:Sec AM/PM (12:30:27 PM)
# %T --> 24 Hour:Min:Sec (16:30:27)
# %X --> Hour:Min:Sec (12:30:27)
# %R --> 24 Hour:Min (16:30)
# %H --> 24 Hour (16)
# %l --> Hour (12)
# %M --> Mins (30)
# %S --> Seconds (09)
# %p --> AM/PM (AM)
# For a more complete list view: https://linux.die.net/man/3/strftime
#colour0 (black)
#colour1 (red)
#colour2 (green)
#colour3 (yellow)
#colour4 (blue)
#colour7 (white)
#colour5 colour6 colour7 colour8 colour9 colour10 colour11 colour12 colour13 colour14 colour15 colour16 colour17
#D ()
#F ()
#H (hostname)
#I (window index)
#P ()
#S (session index)
#T (pane title)
#W (currnet task like vim if editing a file in vim or zsh if running zsh)
" Run
" wget -qO $HOME/.vimrc "https://gist.githubusercontent.com/yogendra/318c09f0cd2548bdd07f592722c9bbec/raw/vimrc"
" After installation goto vim and run
" : PlugInstall
set nobackup
set nowritebackup
set noswapfile
set history=50
set ruler
set showcmd
set number
set tabstop=2
set shiftwidth=2
set shiftround
set expandtab
set noswapfile
set nobackup
set nowb
set nowrap
set linebreak
set wildmode=list:longest
set wildmenu
set wildignore=*.o,*.obj,*~
set wildignore+=*vim/backups*
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=vendor/rails/**
set wildignore+=vendor/cache/**
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=tmp/**
set wildignore+=*.png,*.jpg,*.gif
set scrolloff=8
set sidescrolloff=15
set sidescroll=1
set incsearch
set hlsearch
set ignorecase
set smartcase
set mouse=a
" ----------------------------------------------------------------------------
" Plug
" ----------------------------------------------------------------------------
" Install vim-plug if we don't already have it
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-sensible'
" Colorschemes
Plug 'captbaritone/molokai'
Plug 'altercation/vim-colors-solarized'
Plug 'ajh17/spacegray.vim'
" Syntax
Plug 'tpope/vim-git', { 'for': 'git' }
Plug 'cakebaker/scss-syntax.vim', { 'for': 'scss' }
Plug 'qrps/lilypond-vim', { 'for': 'lilypond' }
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
Plug 'mxw/vim-jsx'
" Completion
Plug 'mattn/emmet-vim', { 'for': 'html' }
" Make % match xml tags
Plug 'tmhedberg/matchit', { 'for': ['html', 'xml'] }
" Make tab handle all completions
Plug 'ervandew/supertab'
" Syntastic: Code linting errors
Plug 'scrooloose/syntastic'
" Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
" Fancy statusline
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Fuzzy file opener
Plug 'ctrlpvim/ctrlp.vim'
" Open from quick-fix-list in new split
Plug 'yssl/QFEnter'
" Respect .editorconfig files. (http://editorconfig.org/)
Plug 'editorconfig/editorconfig-vim'
" Search files using Silver Searcher
Plug 'rking/ag.vim'
" Make Ag searches of selected text
Plug 'Chun-Yang/vim-action-ag'
" Rename/remove files from within vim
Plug 'tpope/vim-eunuch'
" Make commenting easier
Plug 'tpope/vim-commentary'
" Navigate files in a sidebar
Plug 'scrooloose/nerdtree'
" CamelCase motions through words
Plug 'bkad/CamelCaseMotion'
" Split and join lines of code intelligently
Plug 'AndrewRadev/splitjoin.vim'
" Only show cursorline in the current window
Plug 'vim-scripts/CursorLineCurrentWindow'
" Split navigation that works with tmux
Plug 'christoomey/vim-tmux-navigator'
" Change brackets and quotes
Plug 'tpope/vim-surround'
" Make vim-surround repeatable with .
Plug 'tpope/vim-repeat'
" Custom motions
" Indent object
Plug 'michaeljsmith/vim-indent-object'
" Camel Case object
Plug 'bkad/CamelCaseMotion'
"
" Argument object
Plug 'vim-scripts/argtextobj.vim'
" Fugitive: Git from within Vim
Plug 'tpope/vim-fugitive'
" Show git status in the gutter
Plug 'airblade/vim-gitgutter'
" Run Python tests in tmux splits
" Plug 'captbaritone/projects/vim-vigilant', { 'for': 'python' }
Plug '~/projects/vim-vigilant', { 'for': 'python' }
Plug 'benmills/vimux', { 'for': ['python', 'javascript'] }
" Python completion and tag navigation
Plug 'davidhalter/jedi-vim', { 'for': 'python' }
" Wrap and upwrap argument lists
Plug 'FooSoft/vim-argwrap'
" Take notes and keep todo lists in vim
Plug 'vimwiki/vimwiki'
" 'Vastly improved Javascript indentation and syntax support in Vim'
Plug 'pangloss/vim-javascript'
" Visualize undo tree
Plug 'mbbill/undotree'
Plug 'parkr/vim-jekyll'
" Other plugins require curl
if executable("curl")
" Webapi: Dependency of Gist-vim
Plug 'mattn/webapi-vim'
" Gist: Post text to gist.github
Plug 'mattn/gist-vim'
endif
filetype plugin indent on " required!
call plug#end()
" Install minimal vimrc using:
" wget -q https://yogendra.me/minimal-vimrc -O ~/.vimrc
" OR
" curl -sL https://yogendra.me/minimal-vimrc -o ~/.vimrc
set autoindent
set nobackup
set nowritebackup
set noswapfile
set history=50
set ruler
set showcmd
set number
set tabstop=2
set shiftwidth=2
set shiftround
set expandtab
set noswapfile
set nobackup
set nowb
set nowrap
set linebreak
set wildmode=list:longest
set wildmenu
set wildignore=*.o,*.obj,*~
set wildignore+=*vim/backups*
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=vendor/rails/**
set wildignore+=vendor/cache/**
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=tmp/**
set wildignore+=*.png,*.jpg,*.gif
set scrolloff=8
set sidescrolloff=15
set sidescroll=1
set incsearch
set hlsearch
set ignorecase
set smartcase
set expandtab
set number
set hlsearch
set incsearch
let g:netrw_liststyle=3
syntax enable

PCF Tools

This gist has scripts to quickly setup a jumpbox.

  • Downloads tools (cf, om, bbl, etc)
  • Add direnv support
  • Add PCF extensions
  • Setup SSH keys for login from my devices
  • Adds my SSH public keys to authorized_keys
  • Downloads tile/stemcell packages from pivnet
  • Build a jumpbox container image

Update versions

  • Open generate-version.sh
  • Update line with calls to add_version
  • Run ./generate-versions.sh > versions.json
  • Commit changes and push repo

Build Docker Image

You will require:

  1. Docker on you machine

  2. Create a file named secrets.txt with content like following:

    export GIST_URL="https://gist.github.com/yogendra/318c09f0cd2548bdd07f592722c9bbec"
    export OM_PIVNET_TOKEN=ASDSAD_DASDSAD
    export GITHUB_OPTIONS="--http-user github_user --http-password asjhdkjsahd32423jkhkj4i32h432h4jkh2 --auth-no-challenge"
    
    • GITHUB_OPTIONS is optional and should be used if you run into API limit restrictions.
  3. You may need to copy secrets file to docker host in case you are running a VM

    • Docker machine (Example: Machine name myci, host directory /home/docker-user)

      docker-machine scp secrets.txt myci:/home/docker-user/secrets.txt
  4. Create a docker network

    docker network create buildnet
  5. Run a webserver to host secrets and. (Example: Host directory /home/docker-user)

    docker run --name secrets-server --rm --volume /home/docker-user:/usr/share/nginx/html:ro --network buildnet -d nginx

    (Optional) test server by running another container as follows

    docker run --name secrets-server-consumer --rm --network buildnet -t busybox wget -qO- http://secrets-server/secrets.txt
  6. Run the build with following command

    docker build --no-cache --network buildnet --tag yogendra/pcf-jumpbox:latest .
  7. Stop secrets webserver

    docker stop secrets-server
  8. Remove file from Docker host

    docker-machine ssh myci rm /home/docker-user/secrets.txt
FROM ubuntu:latest
ARG build_secret_location=http://secrets-server/secrets.txt
ADD sources.list /etc/apt/sources.list
RUN set -e && \
apt update && \
apt -qqy install sudo wget && \
adduser --disabled-password --gecos '' pcf && \
adduser pcf sudo && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER pcf
ENV PROJ_DIR=/home/pcf
WORKDIR /home/pcf
RUN set -e &&\
eval $(wget -qO- $build_secret_location) && \
wget -qO- "${GIST_URL}/raw/jumpbox-init.sh?$RANDOM" | bash && \
sudo rm -rf /var/lib/apt/lists/*
VOLUME /home/pcf/workspace
# Keep container running as daemon
CMD tail -f /dev/null
#!/usr/bin/env bash
JSON="{"
function add_version {
PROD=$1
VERSION=$2
JSON_ELEMENT="\"${PROD}\": \"${VERSION}\""
if [[ $JSON != "{" ]]; then
JSON="${JSON},"
fi
JSON="$JSON
${JSON_ELEMENT}"
}
function pivnet_version {
product=$1
version="$(pivnet releases -p $product --format json | jq -r '. |= sort_by("release_date") | .[0].version' | sed 's/^v//')"
add_version "$product" "$version"
}
function github_version {
product=$1
repo=$2
version="$(wget ${GITHUB_OPTIONS} -qO- https://api.github.com/repos/$repo/releases | jq -r '. | map(select (.prerelease == false))| .[0].tag_name' | sed 's/^v//')"
[[ $version == "null" ]] && \
version="$(wget ${GITHUB_OPTIONS} -qO- https://api.github.com/repos/$repo/releases | jq -r '.[0].tag_name' | sed 's/^v//')"
add_version "$product" "$version"
}
add_version "terraform" "0.11.14"
pivnet_version "pivotal-function-service"
pivnet_version "pivotal-container-service"
pivnet_version "p-scheduler"
pivnet_version "pcf-app-autoscaler"
pivnet_version "p-event-alerts"
pivnet_version "container-services-manager"
pivnet_version "build-service"
github_version "riff" "projectriff/cli"
github_version "cf" "cloudfoundry/cli"
github_version "docker" "docker/docker-ce"
github_version "buildpack" "buildpacks/pack"
github_version "duffle" "cnabio/duffle"
JSON="$JSON
}"
echo "$JSON" | jq -S
#!/usr/bin/env bash
# Set 2 Environment variables
# PROJ_DIR : Project Directory. All tools will get install under PROJ_DIR/bin. (defaults: /usr/local)
# OM_PIVNET_TOKEN: Pivotal Network Token (required) Its **NOT** ending with -r. It looks like DJHASLD7_HSDHA7
# GITHUB_OPTIONS: (Optional) Provide github userid and token for accessing API.
# Run
# wget -qO- "https://gist.github.com/yogendra/318c09f0cd2548bdd07f592722c9bbec/raw/jumpbox-init.sh?nocache" | OM_PIVNET_TOKEN=DJHASLD7_HSDHA7 bash
# Or to put binaries at your preferred location (example: /home/me/bin), provide PROD_DIR
# wget -qO- "https://gist.github.com/yogendra/318c09f0cd2548bdd07f592722c9bbec/raw/jumpbox-init.sh?nocache" | OM_PIVNET_TOKEN=DJHASLD7_HSDHA7 PROJ_DIR=/home/yrampuria bash
PROJ_DIR=${PROJ_DIR:-$HOME}
export PATH=${PATH}:${PROJ_DIR}/bin
OM_PIVNET_TOKEN=${OM_PIVNET_TOKEN}
[[ -z ${OM_PIVNET_TOKEN} ]] && echo "OM_PIVNET_TOKEN environment variable not set. See instructions at https://gist.github.com/yogendra/318c09f0cd2548bdd07f592722c9bbec#jumpbox-init-sh" && exit 1
echo PROJ_DIR=${PROJ_DIR}
GITHUB_OPTIONS=${GITHUB_OPTIONS}
[[ -d ${PROJ_DIR}/bin ]] || mkdir -p ${PROJ_DIR}/bin
GIST=${1:-https://gist.github.com/yogendra/318c09f0cd2548bdd07f592722c9bbec}
sudo ln -fs /usr/share/zoneinfo/Asia/Singapore /etc/localtime
echo Install basic tools for the jumpbox
OS_TOOLS=(\
apt-transport-https \
build-essential \
bzip2 \
ca-certificates \
coreutils \
curl \
dnsutils \
file \
git \
gnupg2 \
hping3 \
httpie \
iperf \
iputils-ping \
iputils-tracepath \
jq \
less \
man \
mosh \
mtr \
netcat \
nmap \
python2.7-minimal \
python-pip \
rclone \
screen \
shellcheck \
software-properties-common \
tcpdump \
tmate \
tmux \
traceroute \
unzip \
vim \
wamerican \
wget \
whois \
)
sudo apt update && sudo apt install -qqy "${OS_TOOLS[@]}"
VERSION_JSON=$(wget ${GITHUB_OPTIONS} -qO- ${GIST}/raw/versions.json )
function asset_version {
ASSET_NAME=$1
echo ${VERSION_JSON} | jq -r ".[\"$ASSET_NAME\"]"
}
function github_asset {
REPO=$1
EXPRESSION="${2:-linux}"
TAG="${3:-latest}"
ASSET_URL="https://api.github.com/repos/${REPO}/releases/${TAG}"
JQ_EXPR=".assets[] | select(.name|test(\"$EXPRESSION\"))|.browser_download_url"
wget ${GITHUB_OPTIONS} -qO- ${ASSET_URL} | jq -r "${JQ_EXPR}"
}
set -e
# Get updated url at https://github.com/cloudfoundry/bosh-cli/releases/latest
URL="$(github_asset cloudfoundry/bosh-cli linux-amd64)"
echo Downloading: bosh from ${URL}
wget -q ${URL} -O ${PROJ_DIR}/bin/bosh
chmod a+x ${PROJ_DIR}/bin/bosh
# Get updated url at https://www.terraform.io/downloads.html
VERSION=$(asset_version terraform)
URL="https://releases.hashicorp.com/terraform/${VERSION}/terraform_${VERSION}_linux_amd64.zip"
echo Downloading: terraform from ${URL}
wget -q ${URL} -O /tmp/terraform.zip
gunzip -S .zip /tmp/terraform.zip
mv /tmp/terraform ${PROJ_DIR}/bin/terraform
chmod a+x ${PROJ_DIR}/bin/terraform
# Get updated url at https://github.com/cloudfoundry/bosh-bootloader/releases/latest
URL="$(github_asset cloudfoundry/bosh-bootloader linux_x86-64)"
echo Downloading: bbl from ${URL}
wget -q ${URL} -O ${PROJ_DIR}/bin/bbl
chmod a+x ${PROJ_DIR}/bin/bbl
# Get updated url at https://github.com/concourse/concourse/releases/latest
URL="$(github_asset concourse/concourse fly.\*linux-amd64.tgz\$)"
echo Downloading: fly from ${URL}
wget -q ${URL} -O- | tar -C ${PROJ_DIR}/bin -zx fly
chmod a+x ${PROJ_DIR}/bin/fly
# Get updated url at https://github.com/pivotal-cf/om/releases/latest
URL="$(github_asset pivotal-cf/om om-linux.\*tar.gz\$)"
echo Downloading: om from ${URL}
wget -q ${URL} -O- | tar -C ${PROJ_DIR}/bin -zx om
chmod a+x ${PROJ_DIR}/bin/om
# Get updated url at https://github.com/cloudfoundry-incubator/bosh-backup-and-restore/releases/latest
URL="$(github_asset cloudfoundry-incubator/bosh-backup-and-restore bbr-.\*-linux-amd64\$)"
echo Downloading: bbr from ${URL}
wget -q ${URL} -O ${PROJ_DIR}/bin/bbr
chmod a+x ${PROJ_DIR}/bin/bbr
# Always updated version :D
# Get updated url at https://github.com/cloudfoundry/cli/releases/latest
VERSION=$(asset_version cf)
URL="https://packages.cloudfoundry.org/stable?release=linux64-binary&version=${VERSION}&source=github-rel"
echo Downloading: cf from ${URL}
wget -q ${URL} -O- | tar -C ${PROJ_DIR}/bin -zx cf
chmod a+x ${PROJ_DIR}/bin/cf
# Get updated url at https://github.com/cloudfoundry-incubator/credhub-cli/releases/latest
URL="$(github_asset cloudfoundry-incubator/credhub-cli credhub-linux-.\*.tgz\$)"
echo Downloading: credhub from ${URL}
wget -q ${URL} -O- | tar -C ${PROJ_DIR}/bin -xz ./credhub
chmod a+x ${PROJ_DIR}/bin/credhub
# Always updated version :D
# Get updated url at https://storage.googleapis.com/kubernetes-release/release/stable.txt
URL="https://storage.googleapis.com/kubernetes-release/release/$(wget -q -O - https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
echo Downloading: kubectl from ${URL}
wget -q ${URL} -O ${PROJ_DIR}/bin/kubectl
chmod a+x ${PROJ_DIR}/bin/kubectl
# Get updated url at https://github.com/buildpacks/pack/releases/latest
URL="$(github_asset buildpacks/pack pack-v.\*-linux.tgz\$)"
echo Downloading: pack from ${URL}
wget -q ${URL} -O- | tar -C ${PROJ_DIR}/bin -zx pack
chmod a+x ${PROJ_DIR}/bin/pack
# Get updated url at "https://github.com/pivotal-cf/texplate/releases/latest
URL="$(github_asset pivotal-cf/texplate linux_amd64)"
echo Downloading: texplate from ${URL}
wget -q ${URL} -O ${PROJ_DIR}/bin/texplate
chmod a+x ${PROJ_DIR}/bin/texplate
# Get updated url at https://download.docker.com/linux/static/stable/x86_64/
VERSION=$(asset_version docker)
URL="https://download.docker.com/linux/static/stable/x86_64/docker-${VERSION}.tgz"
echo Downloading: docker from ${URL}
wget -q ${URL} -O- | tar -C /tmp -xz docker/docker
mv /tmp/docker/docker ${PROJ_DIR}/bin/docker
chmod a+x ${PROJ_DIR}/bin/docker
rm -rf /tmp/docker
# Get updated url at https://github.com/docker/machine/releases/latest
URL="$(github_asset docker/machine $(uname -s)-$(uname -m))"
echo Downloading: docker-machine from ${URL}
wget -q ${URL} -O ${PROJ_DIR}/bin/docker-machine
chmod a+x ${PROJ_DIR}/bin/docker-machine
# Get updated url at https://github.com/docker/compose/releases/latest
URL="$(github_asset docker/compose $(uname -s)-$(uname -m)\$)"
echo Downloading: docker-compose from ${URL}
wget -q ${URL} -O ${PROJ_DIR}/bin/docker-compose
chmod a+x ${PROJ_DIR}/bin/docker-compose
# Get updated url at https://github.com/projectriff/cli/releases/latest
VERSION=$(asset_version riff)
URL="$(github_asset projectriff/cli linux-amd64 tags/${VERSION})"
echo Downloading: riff from ${URL}
wget -q ${URL} -O- | tar -C ${PROJ_DIR}/bin -xz ./riff
chmod a+x ${PROJ_DIR}/bin/riff
# Get updated url at https://github.com/cloudfoundry-incubator/uaa-cli/releases/latest
URL="$(github_asset cloudfoundry-incubator/uaa-cli linux-amd64)"
echo Downloading: uaa from ${URL}
wget -q ${URL} -O ${PROJ_DIR}/bin/uaa
chmod a+x ${PROJ_DIR}/bin/uaa
# Get updated url at https://github.com/pivotal-cf/pivnet-cli/releases/latest
URL="$(github_asset pivotal-cf/pivnet-cli linux-amd64)"
echo Downloading: pivnet from ${URL}
wget -q ${URL} -O ${PROJ_DIR}/bin/pivnet
chmod a+x ${PROJ_DIR}/bin/pivnet
# Get updated url at https://network.pivotal.io/products/pivotal-container-service/
VERSION=$(asset_version pivotal-container-service)
echo PivNet Download: PKS client ${VERSION}
om download-product -t "${OM_PIVNET_TOKEN}" -o /tmp -v "${VERSION}" -p pivotal-container-service --pivnet-file-glob='pks-linux-amd64-*'
mv /tmp/pks-linux-amd64-* ${PROJ_DIR}/bin/pks
chmod a+x ${PROJ_DIR}/bin/pks
# Get updated url at https://network.pivotal.io/products/pivotal-function-service/
VERSION="$(asset_version pivotal-function-service)"
echo PivNet Download: PFS client ${VERSION}
om download-product -t "${OM_PIVNET_TOKEN}" -o /tmp -v "${VERSION}" -p pivotal-function-service --pivnet-file-glob='pfs-cli-linux-amd64-*'
mv /tmp/pfs-cli-linux-amd64-* ${PROJ_DIR}/bin/pfs
chmod a+x ${PROJ_DIR}/bin/pfs
om download-product -t "${OM_PIVNET_TOKEN}" -o /tmp -v "${VERSION}" -p pivotal-function-service --pivnet-file-glob='duffle-linux-*'
mv /tmp/duffle-linux-* ${PROJ_DIR}/bin/duffle
chmod a+x ${PROJ_DIR}/bin/duffle
# Download build service client
VERSION="$(asset_version build-service)"
echo PivNet Download: Pivotal Build Service client ${VERSION}
om download-product -t "${OM_PIVNET_TOKEN}" -o /tmp -v "${VERSION}" -p build-service --pivnet-file-glob="pb-${VERSION}-linux"
mv /tmp/pb-${VERSION}-linux ${PROJ_DIR}/bin/pb
chmod a+x ${PROJ_DIR}/bin/pb
om download-product -t "${OM_PIVNET_TOKEN}" -o /tmp -v "${VERSION}" -p build-service --pivnet-file-glob="duffle-${VERSION}-linux"
mv /tmp/duffle-${VERSION}-linux ${PROJ_DIR}/bin/pb-duffle
chmod a+x ${PROJ_DIR}/bin/pb-duffle
# Get updated url at https://github.com/projectriff/riff/releases/latest
VERSION=$(asset_version riff)
URL="$(github_asset projectriff/cli linux-amd64 tags/${VERSION})"
echo Downloading: riff from ${URL} ${VERSION}
wget -q ${URL} -O- | tar -C ${PROJ_DIR}/bin -xz ./riff
chmod a+x ${PROJ_DIR}/bin/riff
# Get updated url at https://github.com/sharkdp/bat/releases/latest
VERSION=$(wget ${GITHUB_OPTIONS} -qO- https://api.github.com/repos/sharkdp/bat/releases/latest | jq -r '.tag_name' )
URL="$(github_asset sharkdp/bat x86_64-unknown-linux-gnu tags/${VERSION})"
echo Downloading: bat from ${URL}
wget -q ${URL} -O- | tar -C /tmp -xz bat-${VERSION}-x86_64-unknown-linux-gnu/bat
mv /tmp/bat-${VERSION}-x86_64-unknown-linux-gnu/bat ${PROJ_DIR}/bin/bat
chmod a+x ${PROJ_DIR}/bin/bat
rm -rf /tmp/bat-${VERSION}-x86_64-unknown-linux-gnu
# Get updated url at https://github.com/direnv/direnv/releases/latest
URL="$(github_asset direnv/direnv linux-amd64)"
echo Downloading: direnv from ${URL}
wget -q ${URL} -O ${PROJ_DIR}/bin/direnv
chmod a+x ${PROJ_DIR}/bin/direnv
wget -q "${GIST}/raw/.direnvrc" -O ${HOME}/.direnvrc
# Get updated url at https://network.pivotal.io/products/p-scheduler
VERSION=$(asset_version p-scheduler)
echo PivNet Download: Scheduler CF CLI Plugin ${VERSION}
om download-product -t "${OM_PIVNET_TOKEN}" -o /tmp -v "${VERSION}" -p p-scheduler --pivnet-file-glob=scheduler-for-pcf-cliplugin-linux64-binary-\*
cf install-plugin -f /tmp/scheduler-for-pcf-cliplugin-linux64-binary-*
rm /tmp/scheduler-for-pcf-cliplugin-linux64-binary-*
# Get updated url at https://network.pivotal.io/products/pcf-app-autoscaler
VERSION=$(asset_version pcf-app-autoscaler)
echo PivNet Download: App Autoscaler CF CLI Plugin ${VERSION}
om download-product -t "${OM_PIVNET_TOKEN}" -o /tmp -v "${VERSION}" -p pcf-app-autoscaler --pivnet-file-glob=autoscaler-for-pcf-cliplugin-linux64-binary-\*
cf install-plugin -f /tmp/autoscaler-for-pcf-cliplugin-linux64-binary-*
rm /tmp/autoscaler-for-pcf-cliplugin-linux64-binary-*
# Get updated url at https://network.pivotal.io/products/p-event-alerts
VERSION=$(asset_version p-event-alerts)
echo PivNet Download: Event Alerts CF CLI Plugin ${VERSION}
om download-product -t "${OM_PIVNET_TOKEN}" -o /tmp -v "${VERSION}" -p p-event-alerts --pivnet-file-glob=pcf-event-alerts-cli-plugin-linux64-binary-\*
cf install-plugin -f /tmp/pcf-event-alerts-cli-plugin-linux64-binary-*
rm /tmp/pcf-event-alerts-cli-plugin-linux64-binary-*
echo Installing Keybase cli
wget -q https://prerelease.keybase.io/keybase_amd64.deb -O /tmp/keybase_amd64.deb
sudo apt install -qqy /tmp/keybase_amd64.deb
rm /tmp/keybase_amd64.deb
run_keybase
echo Install google-cloud-sdk
# Add the Cloud SDK distribution URI as a package source
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# Import the Google Cloud Platform public key
wget -qO- https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
# Update the package list and install the Cloud SDK
sudo apt update
sudo apt -qqy install google-cloud-sdk
echo Install aws client
wget -q "https://d1vvhvl2y92vvt.cloudfront.net/awscli-exe-linux-x86_64.zip" -O "/tmp/awscliv2.zip"
unzip /tmp/awscliv2.zip -d $PROJ_DIR
rm -f /tmp/awscliv2.zip
sudo $PROJ_DIR/aws/install
rm -rf $PROJ_DIR/aws
echo Install Azure client
wget -qO- https://aka.ms/InstallAzureCLIDeb | sudo bash
mkdir -p .vim/autoload
wget -q "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" -O ${HOME}/.vim/autoload/plug.vim
wget -q "${GIST}/raw/.vimrc" -O ${HOME}/.vimrc
echo Setting TMUX
wget -q "${GIST}/raw/.tmux.conf" -O ${HOME}/.tmux.conf
echo Put SSH keys
wget -q ${GIST}/raw/keys | while read key; do
wget -qO - "${key}" >> ${HOME}/.ssh/authorized_keys
done
if [[ -z $(cat ~/.bashrc | grep "# ==== ADDED BY jumpbox-init.sh ====") ]]
then
echo Setting up and persisting shell settings
cp ~/.bashrc ~/.bashrc.pre-init-$(date +%Y%m%d-%H%M%S)
cat <<EOF >> ~/.bashrc
# ==== ADDED BY jumpbox-init.sh ====
export PATH=${PROJ_DIR}/bin:\${PATH}
eval "\$(direnv hook bash)"
EOF
fi
source ~/.bashrc
echo Created workspace directory
mkdir -p $PROJ_DIR/workspace/deployments
mkdir -p $PROJ_DIR/workspace/tiles
echo <<EOF
Create your SSH keys
===============================================================================
[[ ! -f ${HOME}/.ssh/id_rsa ]] && \
ssh-keygen -q -t rsa -N "" -f ${HOME}/.ssh/id_rsa && \
cat ${HOME}/.ssh/id_rsa.pub >> ${HOME}/.ssh/authorized_keys
[[ ! -f ${HOME}/.ssh/id_dsa ]] && \
ssh-keygen -q -t dsa -N "" -f ${HOME}/.ssh/id_dsa && \
cat ${HOME}/.ssh/id_dsa.pub >> ${HOME}/.ssh/authorized_keys
EOF
echo Done
https://gist.githubusercontent.com/yogendra/c3ebfc2f5c1bccee7da9c427dad2a472/raw/gandiv.pub
https://gist.githubusercontent.com/yogendra/c3ebfc2f5c1bccee7da9c427dad2a472/raw/mbp15.pub
https://gist.githubusercontent.com/yogendra/c3ebfc2f5c1bccee7da9c427dad2a472/raw/parasu.pub
https://gist.githubusercontent.com/yogendra/c3ebfc2f5c1bccee7da9c427dad2a472/raw/pinaka.pub
#!/usr/bin/env bash
# From an installation project folder (configured to connect to pcf/opsmanager), run following to upload tiles
# wget -qO- "https://gist.github.com/yogendra/318c09f0cd2548bdd07f592722c9bbec/raw/om-install.sh" | bash
function pipe(){
product=$1
version=$2
fileglob=$3
ufileglob=$(echo $fileglob | sed 's/\\//')
echo om download-product --pivnet-api-token $PIVNET_TOKEN --product $product --product-version $version --pivnet-file-glob $fileglob
echo om -k upload-product -p $ufileglob
}
pipe apm '1.6.0' "apm\*.pivotal"
pipe credhub-service-broker '1.2.0' "credhub-service-broker\*.pivotal"
pipe p-cloud-cache '1.6.1' "p-cloud-cache\*.pivotal"
pipe p-dataflow '1.3.1' "p-dataflow\*.pivotal"
pipe p-event-alerts '1.2.6' "p-event-alerts\*.pivotal"
pipe p-healthwatch '1.4.4' "p-healthwatch\*.pivotal"
pipe p-rabbitmq '1.15.3' "p-rabbitmq\*.pivotal"
pipe p-redis '2.0.0' "p-redis-\*.pivotal"
pipe p-scheduler '1.1.4' "p-scheduler\*.pivotal"
pipe p-spring-cloud-services '2.0.5' "p-spring-cloud-services-\*.pivotal"
pipe pivotal-mysql '2.5.3' "pivotal-mysql\*.pivotal"
pipe pivotal_single_sign-on_service 1.7.2 "Pivotal_Single_Sign-On_Service\*.pivotal"
#!/bin/bash
if [ $1 == "shut" -o $1 == "start" ];
then
echo "Running PCF $1 Process..."
else
echo "Only shut or start are valid args!"
exit 1
fi
# These must be explicitly stopped due to nfs_mounter blocking as of 1.6.17
declare -a bootOrder=(
cloud_controller
clock_global
cloud_controller_worker
)
if [ $1 == "shut" ]; then
jobVMs=$(bosh vms --detail|grep partition| awk -F '|' '{ print $2 }')
bosh vm resurrection off
for (( i=${#bootOrder[@]}-1; i>=0; i-- )); do
for x in $jobVMs; do
jobId=$(echo $x | awk -F "/" '{ print $1 }')
instanceId=$(echo $x | awk -F "/" '{ print $2 }')
jobType=$(echo $jobId | awk -F "-" '{ print $1 }')
if [ "$jobType" == "${bootOrder[$i]}" ];
then
#echo MATCHVAL---${bootOrder[$i]} JOBTYPE----$jobType JOBID----$jobId Instance-------$instanceId
bosh -n stop $jobId --hard
fi
done;
done
bosh -n stop --hard
fi
if [ $1 == "start" ]; then
bosh -n start
bosh vm resurrection on
fi
#!/usr/bin/env bash
# wget -q https://yogendra.me/setup-vim | bash
# Or
# curl -sL https://yogendra.me/setup-vim | bash
echo Setup VIM
mkdir -p .vim/autoload
wget -qO $HOME/.vim/autoload/plug.vim "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
wget -q "https://gist.githubusercontent.com/yogendra/318c09f0cd2548bdd07f592722c9bbec/raw/.vimrc" -O $HOME/.vimrc
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-updates main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-backports main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-security main restricted universe multiverse
{
"build-service": "0.0.4",
"buildpack": "0.8.1",
"cf": "6.49.0",
"container-services-manager": "0.6.42",
"docker": "19.03.6",
"duffle": "0.3.5-beta.1",
"p-event-alerts": "1.2.10",
"p-scheduler": "1.2.30",
"pcf-app-autoscaler": "2.0.233",
"pivotal-container-service": "1.6.1",
"pivotal-function-service": "alpha v0.4.0",
"riff": "0.5.0",
"terraform": "0.11.14"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment