Skip to content

Instantly share code, notes, and snippets.

View jweisner's full-sized avatar
🤔

Jesse Weisner jweisner

🤔
  • BCIT
  • Vancouverish, BC
View GitHub Profile
@jweisner
jweisner / backup.sh
Last active February 12, 2021 02:17
Backup manager shell script
#!/bin/bash
# NOTE: this requires a modern /usr/bin/date to work. None of this works on Alpine.
###
# config
backupname='bar' # name of the thing you're backing up
source='/home/jweisner/foo' # your directory to be backed up
dest='/home/jweisner/backups' # where your backups go
oc get pod --all-namespaces | awk '{if ($4=="Evicted") print "oc delete pod " $2 " -n " $1;}' | sh
local flap_up_switch_number = 181
local flap_mid_switch_number = 267
local flap_down_switch_number = 182
local laste_up_switch_number = 186
local laste_mid_switch_number = 270
local laste_down_switch_number = 187
local condition_lever_low = 0.50
local HAS3POSFLAP = false
@jweisner
jweisner / ocrestart.sh
Created February 10, 2020 18:00
Restart deploymentConfig/daemonSet/statefulSet by adding an annotation with the current date/time
ocrestart() {
oc whoami >/dev/null 2>&1 || oc login || exit $?
[ -z "$1" ] && echo "Usage: ocrestart deploymentconfig/name" && exit 1
oc patch $1 --patch "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"last-restart\":\"`date +'%s'`\"}}}}}"
}
@jweisner
jweisner / ocbusybox.sh
Created February 10, 2020 17:58
Launch a BusyBox pod in the current OpenShift project
ocbusybox() {
oc whoami >/dev/null 2>&1 || oc login || exit $?
oc run -i --tty --image busybox busybox-$$ --restart=Never --rm
}
@jweisner
jweisner / delete_all_users.sh
Last active October 24, 2019 23:28
OpenShift kibana user index reset
for i in $(oc get users|grep -v NAME|awk '{print $1;}');do
delete_kibana_index.sh $i
done
@jweisner
jweisner / puppetmaster.sh
Created October 24, 2019 21:20
Get shell in OpenShift pod example
puppetmaster() {
oc whoami >/dev/null 2>&1 || oc login || exit $?
pod=$(oc get pods -n puppet -l app=puppetserver|grep Running|head -n1|awk '{print $1;}')
[ -z "${pod}" ] && exit 1
if [ -z "$*" ];then
cmd="/bin/bash"
else
cmd="$*"
fi
oc rsh -n puppet ${pod} $cmd
gpg --with-fingerprint --with-keygrip --dry-run --import --import-options import-show

Keybase proof

I hereby claim:

  • I am jweisner on github.
  • I am jweisner (https://keybase.io/jweisner) on keybase.
  • I have a public key whose fingerprint is 0B63 5722 5D8A 8A66 2BDD A862 B6CC C34F 257D 63DD

To claim this, I am signing this object: