Skip to content

Instantly share code, notes, and snippets.

View linosteenkamp's full-sized avatar

Lino Steenkamp linosteenkamp

  • Cape Town South Africa
View GitHub Profile
@linosteenkamp
linosteenkamp / yubikey-gpg-ssh-git.md
Last active October 4, 2023 06:32 — forked from djsplice/yubikey-gpg-ssh-git.md
Yubikey - PGP - SSH - Git Signing
@linosteenkamp
linosteenkamp / CopyCertToMikrotik.sh
Created March 15, 2023 14:33
A script to copy a LetsEncrypt wildcard certificate to a MikroTik router
#!/bin/bash
pemFiles=/etc/letsencrypt/live/steenkamps.org/*.pem
pemMd5=/etc/letsencrypt/live/steenkamps.org/pem.md5
certPath=/etc/letsencrypt/live/steenkamps.org
cert=cert.pem
key=privkey.pem
sshIdentity=/root/.ssh/id_rsa
mikrotikUser=admin
mikrotikIp=192.168.1.254
@linosteenkamp
linosteenkamp / update_do_ip.sh
Last active September 6, 2019 08:44
Dynamic Dns update script to update DigitalOcean DNS Zone record
#!/bin/bash
DNS_FILE="$HOME/.my_public_ip"
SUCCESS="200"
DO_API_KEY=""
DO_DOMAIN=""
DO_DNS_RECORD_ID=""
#- Get public ip
ip=$(curl --silent api.ipify.org)
@linosteenkamp
linosteenkamp / get_kubectl_certs.sh
Last active September 3, 2019 07:35
Extract certificates from kubectl config
#!/bin/bash
CKD_KEY="client-key-data"
CCD_KEY="client-certificate-data"
CAD_KEY="certificate-authority-data"
json=$(kubectl config view --raw -o json)
#- Retrieve Certificates and Keys for all contexts
echo "$json" | jq -c '.contexts[].context' | while read line
backup_path="~/sql_restore/"
dbs=$(find $backup_path -type f -name "*.gz" | sort)
echo "========================== Restore Database ===================================="
for db in $dbs;
do
dbname=`echo $db | basename $db | awk '{print substr($0, 1, index($0, ".") -1 )}'`
#! /bin/bash
BACKUP_DESTINATION="/Users/linosteenkamp/Database/Backups"
MYSQL_CONNECTION="aax-k8s-mysql-develop"
display_usage() {
if ! command -v mysql_config_editor > /dev/null; then
Echo "MySQL not Installed!"
Echo "Please install MySQL before using this script"
exit 1
#!/bin/bash
# Add md5 hash to the end every line in a CSV file
# Usage ./hash_csv_records.sh input.csv > output.csv
input="${1:-/dev/stdin}"
SEP=";"
if [[ $(uname) == 'Linux' ]]; then
@linosteenkamp
linosteenkamp / speedtest2api.sh
Last active August 25, 2018 20:50
Execute speedtest-cli and write results to speedtest-api
#!/bin/bash
# URL for speedtest-api (Change this to match your setup)
URL="localhost:3000/api/test/create"
# Path to speedtest-cli (Change this to match the path to your speedtest-cli executable)
SPEEDTEST_CLI_PATH="/usr/local/bin/speedtest-cli"
# Input Field Seperator for splitting the CSV result into an array
IFS=","
@linosteenkamp
linosteenkamp / speedtest.sh
Last active August 29, 2021 16:11
Execute speedtest-cli and store result in sqlite database
#!/bin/bash
# Path to speedtest-cli (Change this to match the path to your speedtest-cli executable)
SPEEDTEST_CLI_PATH="/usr/local/bin/speedtest-cli"
# Path to the sqlite database (Change this to suit your needs)
#DB_PATH="/home/lino/speedlog.db"
DB_PATH="/var/www/speedtest-api/speedtest.db"
# Create test table SQL statement
@linosteenkamp
linosteenkamp / csv2json.sh
Last active April 11, 2021 16:51 — forked from DecisionNerd/csv2json.sh
CSV to JSON converter using BASH. Original script from http://blog.secaserver.com/2013/12/convert-csv-json-bash/
#!/bin/bash
# CSV to JSON converter using BASH
# original script from https://gist.github.com/dsliberty/3de707bc656cf757a0cb
# Usage ./csv2json.sh input.csv > output.json
shopt -s extglob
input="${1:-/dev/stdin}"
SEP=","