Skip to content

Instantly share code, notes, and snippets.

View brianredbeard's full-sized avatar

redbeard brianredbeard

View GitHub Profile
@brianredbeard
brianredbeard / ext_mirror.sh
Created September 26, 2018 05:19
Call external script from udev rule - I use this mechanism to fire off xrandr rules when docking my laptop.
#!/bin/sh
# This script will make two connected output sources mirrors of each other:
#
#
# +---------------+ +---------------+
# | | | |
# | Primary | | DisplayLink |
# | Display | | (DP-2-2) |
# | (e-DPI-1) | | (Screen 2/3) |
@brianredbeard
brianredbeard / gh-pubkeys.sh
Created February 11, 2019 23:16
Github Pubkeys - grab all keys from a list of users to generate an authorized_keys file
#!/bin/bash
set -e -u -o pipefail
# Provide a default list of users. This can be overriden by supplying the
# environment variable "USERS"
USERS=${USERS:-'brianredbeard chancez crawford ivancherepov kbrwn'}
for name in ${USERS}; do
curl -Ls http://github.com/${name}.keys | \
@brianredbeard
brianredbeard / Dockerfile-OSSEC-HIDS
Created December 1, 2017 16:57
Minimal Dockerfile for the OSSEC host based intrusion detection system
####
#
# BUILD CONTAINER
#
####
FROM alpine:latest as build
# Setup a work environment and retrieve the sources
@brianredbeard
brianredbeard / quicknum.py
Created May 23, 2019 18:59
quicknum - a script to quickly convert/print binary, hex, and decimal numbers
#!/usr/bin/env python
import re
import sys
x=sys.argv[1]
# Check to see if the string is only binary
nonbin = re.search(r'[2-9A-Fa-f]', x)
# First, check to see if there were matches in binary, if not
@brianredbeard
brianredbeard / rhcos-urls.py
Created May 31, 2019 19:16
Generate URLs for Red Hat CoreOS Images
#!/usr/bin/env python3
# requires the requests library:
# pip install requests
import requests
import json
RHCOS_BUILDS="https://raw.githubusercontent.com/openshift/installer/master/data/data/rhcos.json"
@brianredbeard
brianredbeard / rpm2mc.py
Created July 9, 2019 18:25
rpm2mc.py - a tool to convert RPMs to Kubernetes machine-configs
#!/usr/bin/env python3
#
# rpm2mc.py -- Generate a Kubernetes machine-config from an RPM
# Copyright (c) 2019 Brian 'redbeard' Harrington <redbeard@dead-city.org>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
@brianredbeard
brianredbeard / os4-acme-certs.sh
Last active July 23, 2019 20:31
Script to get Let's Encrypt public facing certs for an OpenShift v4 cluster
#!/bin/sh
DOMAIN="${1}"
EMAIL="${2}"
if [ "${#}" -ne 2 ]; then
echo "USAGE: os4-acme-certs.sh clustername.basedomain.tld email@example.com"
echo "QUITTING"
exit 1
fi
@brianredbeard
brianredbeard / pine64-battery.sh
Last active August 23, 2019 23:32 — forked from pfeerick/pine64-battery.sh
Colourful Battery Status script for Pine64 SOC board
#!/bin/bash
SWITCH="\033["
NORMAL="${SWITCH}0m"
RED="${SWITCH}1;31m"
GREEN="${SWITCH}1;32m"
YELLOW="${SWITCH}1;33m"
PURPLE="${SWITCH}1;35m"
BLUE="${SWITCH}1;34m"
CYAN="${SWITCH}1;36m"
@brianredbeard
brianredbeard / db_dump.sh
Last active August 26, 2019 22:04
MariaDB / MySQL Backup script
#!/bin/bash
# Simple script to dump the contents of a database into separate files in the directory "/backups/"
# Symlink into /etc/cron.daily/ or add to crontab
# Originally from: https://gist.github.com/brianredbeard
# /usr/local/scripts/db_dump
#mysqldump -x --add-drop-table --all-databases > /backups/mysqldb-`date +%F-%I%p`.sql
/usr/bin/mysql --defaults-extra-file=/root/.my.cnf -e 'show databases' | /bin/awk '{print $1}' | /bin/grep -v "^Database$" | /usr/bin/xargs -i{} /usr/bin/mysqldump --defaults-extra-file=/root/.my.cnf --opt -Q -r /backups/{}-`date +%F-%I%p`.sql {}
@brianredbeard
brianredbeard / alt-catalog.yaml
Created September 10, 2019 16:23
Alternative OpenShift Operator Catalog
# This is a sample config used to pull content in from Quay.io
# and present it as published content through the in cluster Operator Catalog
# atop OpenShift.
# https://github.com/operator-framework/operator-marketplace/blob/master/README.md
#
# To use this change:
# OperatorSource
# - metadata.name
# - spec.registryNamespace
# - spec.displayName