Skip to content

Instantly share code, notes, and snippets.

View rahulkj's full-sized avatar

Rahul Jain rahulkj

  • VMware
  • Dallas, TX
View GitHub Profile

Keybase proof

I hereby claim:

  • I am rahulkj on github.
  • I am rahulkj (https://keybase.io/rahulkj) on keybase.
  • I have a public key whose fingerprint is 071D 7221 17EB C5D9 4E96 93FC DB75 927F 7A84 5B27

To claim this, I am signing this object:

get_latest_release() {
DOWNLOAD_URL=$(curl --silent "https://api.github.com/repos/$1/releases/latest" | \
jq -r \
--arg flavor $2 '.assets[] | select(.name | contains($flavor)) | .browser_download_url')
echo $DOWNLOAD_URL
}
get_latest_release "cloudfoundry-incubator/credhub-cli" "linux"
@rahulkj
rahulkj / install_cli.sh
Last active November 3, 2022 03:06
install_cli.sh
#!/bin/bash -ex
export DEBIAN_FRONTEND=noninteractive
declare -a DEPENDENCIES=(tar wget gzip ruby gem jq curl)
LOGFILE=/dev/null
OUTPUT=/usr/local/bin
URLS_CF='https://packages.cloudfoundry.org/stable?release=linux64-binary&source=github'
@rahulkj
rahulkj / azure-create-sp.sh
Last active February 22, 2019 16:42
Azure create service principal
#!/bin/bash -e
SERVICE_PRINCIPAL_NAME=http://rj-BOSHAzureCPI
read -s -p "Enter Password for service principal user $SERVICE_PRINCIPAL_NAME: " CLIENT_SECRET
AZ_ACCOUNT=$(az login)
SUBSCRIPTION_ID=$(echo "$AZ_ACCOUNT" | jq -r '.[] | .id')
TENANT_ID=$(echo "$AZ_ACCOUNT" | jq -r '.[] | .tenantId')
@rahulkj
rahulkj / install_clis_mac.sh
Last active February 5, 2024 04:42
install_clis_mac.sh
#!/bin/bash -e
# Determine latest ruby version
DEFAULT_RUBY_VERSION=$(curl https://cache.ruby-lang.org/pub/ruby/index.txt | tail -1 | awk '{split($0,a," "); print a[1]}' | cut -d'-' -f2)
# Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# Install gpg
brew install gnupg
@rahulkj
rahulkj / transfer-all-repos.sh
Created June 27, 2019 10:11
Script to transfer all the git repos from one org to another
#!/bin/bash -x
export GIT_USER=
export GIT_TOKEN=
export ORG_NAME=
export NEW_ORG_NAME=
export OUTPUT_FILE=repos.json
rm -rf $OUTPUT_FILE
@rahulkj
rahulkj / update-git-repos.sh
Created August 23, 2019 15:04
Update git repositories
#!/bin/bash
read -e -p "Enter the git directory:" FOLDER
pushd $FOLDER
while read -r line; do
pushd $line
git pull
popd
@rahulkj
rahulkj / helm-image-pull-push.sh
Last active March 27, 2020 15:32
Docker pull and push to harbor
#!/bin/bash
export DOCKER_CONTENT_TRUST=0
export HARBOR_HOST=harbor.pks.homelab.io
export HARBOR_USERNAME=admin
export HARBOR_PASSWORD=welcome
export HARBOR_REPO=$HARBOR_HOST/prometheus-operator
docker login $HARBOR_HOST -u $HARBOR_USERNAME -p $HARBOR_PASSWORD
@rahulkj
rahulkj / pipeline.yml
Last active August 20, 2020 17:37
Nexus Test Pipeline
resource_types:
- name: pivnet
type: docker-image
source:
repository: pivotalcf/pivnet-resource
tag: latest-final
- name: static
type: docker-image
source:
repository: eugenmayer/concourse-static-resource
@rahulkj
rahulkj / gitlab-clone-groups
Created July 22, 2021 21:22
Snippet to clone repos under a group in gitlab
#!/bin/bash -ex
GITLAB_URL=https://gitlab.<hello>.com/
GITLAB_TOKEN=
if [ -z "$GITLAB_URL" ]; then
echo "Missing environment variable: GITLAB_URL (e.g. https://gitlab.com)"
exit 1
fi