Skip to content

Instantly share code, notes, and snippets.

View abn's full-sized avatar

Arun Babu Neelicattu abn

View GitHub Profile
@abn
abn / keycloak-fetch-token-postman-pre-request.js
Created October 12, 2017 13:02
A postman pre-request script to fetch a valid token from Red Hat SSO (Keycloak) and set it to a template variable to use in request headers.
// modify these configurations to work with your environment
var server = "https://sso.example.com";
var realm = "realm";
var resource = "client";
var username = "username";
var password = "url encoded password";
var url = `${server}/auth/realms/${realm}/protocol/openid-connect/token`;
var data = `grant_type=password&client_id=${resource}&username=${username}&password=${password}`;
@abn
abn / loadbins.sh
Last active March 30, 2018 08:39
Helper script to find and copy shared library files given a binary.
#!/bin/sh
DEST=${DEST-rootfs}
function loadfiles() {
for FILE in $1
do
echo "Loading ${FILE}"
mkdir -p ${DEST}$(dirname ${FILE})
cp ${FILE} ${DEST}${FILE}
@abn
abn / Makefile-json-to-var
Last active August 7, 2017 11:12
Makefile snippet: json -> shell env var
# delete a line in an environment file that sets a var
# env_del(var,file)
define env_del
@{ [[ ! -e "$(2)" ]] || sed -i /'$(1)='/d $(2); } || :
endef
# given a env var name and json file, minify and add to specified file
# env_minify_json(var, json, dest)
define env_minify_json
$(call env_del,$(1),$(3))
@abn
abn / 00-lenovo-x1-5th-gen-thinkfan-setup.md
Last active January 30, 2024 19:31
Fedora thinkfan configuration for Lenovo X1 Carbon (5th Gen)

Thinkfan Configuration Notes

This are notes for configuration thinkfan for Fedora. This configuration procedure was followed on a Lenovo Thinkpad X1 Carbon (5th Gen) running Fedora 25.

Non standard (default) configuration was required for this machine as the default sensors are not available. Eg: /proc/acpi/ibm/thermal does not exist for this model.

An annoted configuration file has been included below. However, there is no guarentee that this will work as-is on every machine.

Installation

dnf -y install thinkfan
@abn
abn / openshift-jq-remove-trigger.sh
Created June 23, 2017 05:09
openshift-jq: remove triggers example
jq '.spec.triggers |= map(select(contains({"type": "ImageChange"}) | not))'
@abn
abn / openshift-debug-s2i-build.md
Last active May 27, 2017 10:38
OpenShift Debugging: S2I Build Failures

OpenShift Debugging: S2I Build Failures

Notes for debugging s2i build issues locally without having to run through the change-push-build model and to allow for some flexibility when debugging. This helps in identifying any issues in the application build process or incompatibilities with any of the s2i stages.

Requirements

  1. You have docker, s2i and openshift-cli installed locally.
  2. openshift-cli is logged in to the correct cluster.

Prepare Docker Repository Access

Login to repository

OpenShift Developer Cluster on OSX

This document details how to bring up an OpenShift local cluster on Mac OSX. We also detail how to do the same under a proxied environment.

System Requirements

  1. Docker for Mac (stable). Note that this will also work with Docker Toolbox for Mac, however this is untested and could have issues with networking.
  2. Homebrew package manager for macOS. If you are installing from behind a proxy, use the script available at this gist.

Install OpenShift CLI

The openshift-cli can be installed via homebrew. This package provides us with the oc binary.

@abn
abn / install-homebrew-osx.sh
Last active January 5, 2023 09:24
Install homebrew from behind a proxy on Mac OS X.
#!/usr/bin/env bash
# Based on: http://godlessheathenmemoirs.blogspot.com.au/2015/03/homebrew-aka-brew-on-mac-os-x-behind.html
function usage() {
echo 2>&1 ""
echo 2>&1 "usage: $(basename $0) PROXY_HOST PROXY_PORT"
exit 1
}
PROXY_HOST=${PROXY_HOST:-$1}
@abn
abn / rpm-build-workflow.md
Last active May 18, 2022 05:04
RPM build and hosting workflow using github, travis-ci and copr

RPM Build Flow

This document details a simple RPM build flow pattern used to build and host RPM artifacts for open source projects. The below is a visual summary of this flow.

In order to achieve this multiple tools and services are used. The services and their purpose in the flow is as listed below.

Service Purpose
GitHub As is the most common use for GitHub, it holds the build source code. In this case we hold only the spec files and related source files. All other sources, including project binaries/sources are retrieved at build time.
# .bashrc.docker
# get id of last container started
docker-last() { docker ps -l -q ;}
# http://www.commandlinefu.com/commands/view/15050/attach-to-bash-shell-in-the-last-container-you-started
docker-exec() { docker exec -i -t $(docker-last) ${@-bash} ;}
# get ip of container with given id (default: last started container)
docker-ip() { docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${1-$(docker-last)} ;}