Skip to content

Instantly share code, notes, and snippets.

View JonTheNiceGuy's full-sized avatar

Jon "The Nice Guy" Spriggs JonTheNiceGuy

View GitHub Profile
@JonTheNiceGuy
JonTheNiceGuy / AAA_Readme for wp-upgrade.sh.md
Created June 5, 2020 07:20
A simple script to upgrade all wordpress components in cron

wp-update.sh

A simple tool to update and upgrade Wordpress components

A few years ago, I hosted my blog on Dreamhost. They've customized something inside the blog which means it doesn't automatically update itself. I've long since moved this blog off to my own hosting, but I can't figure out which thing it was they changed, and I've got so much content and stuff in here, I don't really want to mess with it.

Anyway, I like keeping my systems up to date, and I hate logging into a blog and finding updates are pending, so I wrote this script. It uses wp-cli which I have installed to /usr/local/bin/wp as per the install guide.

Using Vagrant with Multi-Node MicroK8S to experiment with Kubernetes

This script (using Vagrant) is used to build a pair of Ubuntu based virtual machines that have the MicroK8S setup of Kubernetes.

It also installs docker, and sets up aliases for kubectl in line with the MicroK8S documentation.

Please note that this script relies on the fact that Vagrant transfers files in /vagrant to the host file system, which we can then use to setup the second node.

@JonTheNiceGuy
JonTheNiceGuy / Vagrant + MicroK8S - README.md
Last active February 29, 2024 08:07
Using Vagrant with MicroK8S to experiment with Kubernetes
blueprint:
name: Turn off Light after Time has elapsed
description: Given a light entity, watch for it turning on, and then turn it off after a certain period of time.
domain: automation
input:
light:
name: Light
description: Select the light to monitor and control
selector:
entity:

Sanitized Outlook Event Forwarding

This is an example of what I use with my work calendar, when I need to forward something to my personal calendar.

This macro does not include any of the meeting content (who will be there, what the content is), but is just to block out the time to prevent your personal and professional lives from overlapping. This macro will create a new appointment for the time window, optionally including the subject (or replace it with [WORK]) and optionally including the location (or replace it with [WORK]).

After the invite has been sent, it deletes the invite, so it doesn't look like you've got two meetings at the same time.

blueprint:
name: Turn off Switch after Time has elapsed
description: Given a switch entity, watch for it turning on, and then turn it off after a certain period of time.
domain: automation
input:
switch:
name: Switch
description: Select the switch to monitor and control
selector:
entity:

PHPIPAM Bulk Add Subnets.py

This is a simple script to help build up a load of subnets in quick order!

Add your subnets to the list starting at line 76 called "make_subnets", run pip3 install -r requirements.txt and then python3 phpipam_bulk_add_subnets.py

Your result should be like this:

@JonTheNiceGuy
JonTheNiceGuy / wait_for_network.sh
Last active May 17, 2023 10:06
Wait for the NIC to be assigned an IP address, then wait for google's DNS to respond, and then sleep for rand(30,600), used like this `wait_for_network.sh && do_something`
#! /bin/bash
# This script checks that the interface is up, and that an internet connection is available
# It is based on code from http://askubuntu.com/questions/3299/how-to-run-cron-job-when-network-is-up
#
# Then it sleeps for a random number of seconds between 30 and 600.
# This is based on code from http://tldp.org/LDP/abs/html/randomvar.html
#
# Collated by @JonTheNiceGuy on 2015-10-15
# Fix from @p1r473 on 2023-05-17 with thanks!
@JonTheNiceGuy
JonTheNiceGuy / get_cert_digest.bash
Created May 5, 2023 16:08
A bash script which gets the certificate SHA256 hashes of certificates in a chain, or for an individual certificate
#!/bin/bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
cleanup() {
trap - SIGINT SIGTERM ERR EXIT
if [ -z "${KEEP:-}" ] && [ -n "${tempdir:-}" ]
then
rm -Rf "$tempdir"
fi
@JonTheNiceGuy
JonTheNiceGuy / Turn Off Switch After Time.yaml
Last active February 19, 2023 13:24
Deprecated - uses wrong selector
blueprint:
name: Turn off Switch after Time has elapsed
description: Given a switch entity, watch for it turning on, and then turn it off after a certain period of time.
domain: automation
input:
switch:
name: Switch
description: Select the switch to monitor and control
selector:
entity: