Skip to content

Instantly share code, notes, and snippets.

View Chaz6's full-sized avatar

Chris Hills Chaz6

View GitHub Profile
@Chaz6
Chaz6 / build-llvm-on-almalinux.bash
Last active April 14, 2024 15:24
build-llvm-on-almalinux.bash
#!/usr/bin/bash
LLVM_VERSION=18.1.3
LLVM_VERSION_BETA=
PREFIX=$HOME
if [ -n "$LLVM_VERSION_BETA" ]; then
FILENAME="llvm-project-${LLVM_VERSION}${LLVM_VERSION_BETA}.src.tar.xz"
INSTALL_PREFIX="$PREFIX/.local/local/llvm-${LLVM_VERSION}${LLVM_VERSION_BETA}"
@Chaz6
Chaz6 / build-python-on-almalinux.bash
Created April 14, 2024 15:20
build-python-on-almalinux.bash
#!/usr/bin/bash
PYTHON_VERSION=3.13.0
BETA_VERSION=a6
INSTALLDIR="${HOME}"/.local/local
cd /tmp &&
wget -4 "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}${BETA_VERSION}.tar.xz" &&
echo "Extracting archive..." &&
tar xvf "Python-${PYTHON_VERSION}${BETA_VERSION}.tar.xz" &&
@Chaz6
Chaz6 / readme.md
Last active February 14, 2024 15:19
How to replace UEFI Secure Boot certificates in VMware

Custom Secure Boot configuration while deploying a new Virtual Machine

The Secure Boot configuration is stored in NVRAM. If the NVRAM contains no Secure Boot configuration (a freshly deployed VM, or a VM for which the .nvram file has been deleted from the datastore), the Secure Boot configuration will be reset to the defaults described in the UEFI Specification (the variables named PKDefault, KEKDefault, dbDefault and dbxDefault). You can use advanced VM config options to control those defaults, through which you can pre-populate the Secure Boot configuration before the VM is first powered on.

If you want to deploy the certificates as part of the VM's configuration, copy the DER-encoded certificate into the VM's directory and add the following advanced VM config options:

uefi.secureBoot.dbDefault.file0 = "custom-cert.der"

where "custom-cert.der" is the name of the DER-encoded certificate file within the VM's directory. You can repeat that for file1, file2, file3, etc., to add multiple certificate

@Chaz6
Chaz6 / update-weechat-ssl-letsencrypt.bash
Last active August 22, 2022 11:35
Script to update weechat relay ssl certificate using LetsEncrypt
#!/bin/bash
/usr/bin/certbot renew
if /usr/bin/test $(find /etc/letsencrypt/live/weechat.example.com/cert.pem -mmin -60)
then
/bin/cat /etc/letsencrypt/live/weechat.example.com/cert.pem /etc/letsencrypt/live/weechat.example.com/privkey.pem > /home/user/.weechat/ssl/weechat.example.com_ssl.pem
/bin/cat /etc/letsencrypt/live/weechat.example.com/fullchain.pem > /home/user/.weechat/ssl/weechat.example.com_fullchain.pem
/usr/bin/su -c 'echo "*/relay sslcertkey" > /home/user/.weechat/weechat_fifo_*' user
fi
@Chaz6
Chaz6 / jnh_exception_packet_trace.rb
Created May 19, 2022 12:05 — forked from ytti/jnh_exception_packet_trace.rb
script to turn JunOS Trio exception capture into a PCAP
#!/usr/bin/env ruby
# script to generate PCAP from Trio exception trace. Potentially you may need to change POP_BYTES variable.
# Trio exception trace allows you to capture things like broken packets (checksum error), to see who is sending them
# clogin junos-trio-box | tee exception_trace
# start shell pfe network fpc0
# show jnh 0 exceptions terse
# debug jnh exceptions N discard ## get N from above command
# debug jnh exceptions-trace
@Chaz6
Chaz6 / fetch-ipset-from-asn.bash
Last active May 13, 2022 07:46
Generate an ipset for a given autonomous system number
#!/bin/bash
usage()
{
echo "Usage: $0 [ASN]"
}
if [ $# -ne 1 ]; then
usage
exit 1
@Chaz6
Chaz6 / domains.txt
Last active December 18, 2021 14:35
Generate a hosts file using DNS64
www.example.com 93.184.216.34
@Chaz6
Chaz6 / GetOrgChartFromActiveDirectory.pl
Created October 19, 2012 10:19
Create organizational chart from Active Directory
#!/usr/bin/perl -w
########################################################################################
# This script connects to a domain controller and produces an organizational chart.
#
# It is based on the script at the following page:-
# http://thelowedown.wordpress.com/2008/05/27/generate-calltree-from-active-directory/
#
# Chris Hills (chaz@chaz6.com)
# 2012/10/19
@Chaz6
Chaz6 / python39-patch-sqlite-trace-v2.patch
Created October 13, 2020 15:45
Patch to support current SQLlite with Python 3.9
--- Python-3.9.0/Modules/_sqlite/connection.c.old 2020-10-05 16:07:58.000000000 +0100
+++ Python-3.9.0/Modules/_sqlite/connection.c 2020-10-13 16:40:28.161985539 +0100
@@ -1063,10 +1063,10 @@
if (trace_callback == Py_None) {
/* None clears the trace callback previously set */
- sqlite3_trace(self->db, 0, (void*)0);
+ sqlite3_trace_v2(self->db, SQLITE_TRACE_STMT, 0, (void*)0);
Py_XSETREF(self->function_pinboard_trace_callback, NULL);
} else {
@Chaz6
Chaz6 / update-ssl-certs.bash
Last active April 25, 2020 17:57
Script to update ssl certificates for nginx, unifi and weechat using certbot and systemd
#!/bin/bash
UNIFI_DOMAIN="unifi.example.com"
WEECHAT_DOMAIN="weechat.example.com"
WEECHAT_USER="username"
DOMAIN_LIST="$UNIFI_DOMAIN $WEECHAT_DOMAIN www.example.com"
########################################################################
#
# Program header