Skip to content

Instantly share code, notes, and snippets.

View ThinGuy's full-sized avatar

craig bender ThinGuy

View GitHub Profile
@ThinGuy
ThinGuy / maas-paths.txt
Created October 21, 2025 17:05
MAAS Paths
export RACK=<MAAS_RACK_IP>
export REGION=<MAAS_REGION_IP>
Boot Files:
=====================
curl -sSlL http://$RACK:5248/images/|awk -F'>|<' '/^<a href/{print $3,$5}'
## Test pulling static file via tftp (requires install tftp-hpa package):
### tftp -m binary $RACK -c get <filename from above>
@ThinGuy
ThinGuy / pkgcmp.sh
Last active October 14, 2025 17:13
Quickly check what component (main, universe,etc) . Supports simple regex (via 'apt-cache search -n').
pkgcmp() {
for P in $(apt-cache search -n "${@}"|awk -F' - ' '{print $1}');do
[[ -z ${P} ]] && { continue; };
printf "${P}: $(apt-cache show ${P}|awk '/^Section:/&&!/^$/{if ($2 !~ /\//) print "main";else {gsub(/\/.*/,"",$2);print $2}}')\n";
done
};export -f pkgcmp
@ThinGuy
ThinGuy / change-install-repo.sh
Created October 7, 2025 17:03
Change security.ubuntu.com with us.archive.ubuntu.com for geo-fenced installed.
#!/bin/bash
# Create Directory
mkdir -p ~/www
# Enter directory
cd ~/www
# Create autoinstall.yaml
cat > ~/www/user-data << 'EOF'
@ThinGuy
ThinGuy / geoip.sh
Created October 2, 2025 15:03
Get ipinfo of an FQDN
# prereqs: dnsutils jq
# sudo apt install jq dnsutils -y
geoip() {
dig +short ${@}| \
xargs -rn1 -P1 bash -c \
'curl -sSlL ipinfo.io/${0}|jq -r '"'"'"\(.hostname)\n\(.ip)\n\(.city)\n\(.region)\n\(.country)"'"'"'|paste -sd,'|\
sort -t, -k5V
};export -f geoip
@ThinGuy
ThinGuy / papi-pull.sh
Created September 4, 2025 17:37
Pull all repo sizes from Canonical - WIP
#!/bin/bash
export PAPI_DIR=~/papi
[[ -d ${PAPI_DIR} ]] && { find ${PAPI_DIR} -type f -delete; } || { mkdir -p $PAPI_DIR; }
export OK=$(printf '\e[0;1;38;2;0;255;0m✓\e[0m')
export ORA=$(printf '\e[0;1;38;2;233;84;20m▸\e[0m')
export WRA=$(printf '\e[0;1;38;2;255;255;255m▸\e[0m')
printf "\n\e[2G\e[0;38;2;255;255;255mCanonical \e[0;38;2;233;84;20mPAPI\e[0m: Project and Package Information\e[0m\n"
LINE="$(printf '\u2500%0.0s' {1..47})"
printf "\e[2G${LINE}\n"
@ThinGuy
ThinGuy / ob-mc.sh
Created August 21, 2025 17:09
Meshcommander Setup for Canonical Orangeboxes (run on node00)
#!/bin/bash
# Meshcommander (AMT Management) for Orangeboxes
sudo apt update
sudo apt install nodejs npm -fqy --auto-remove --purge;
sudo mkdir -p /srv/mc;
sudo chown -R $(id -un 1000):$(id -gn 1000) /srv/mc
sudo find /srv/mc -type d -exec chmod u+rwx,g+rwx,o+rx {} \; -o -type f -exec chmod u+rw,g+rw,o+r {} \;
(cd /srv/mc && npm install meshcommander);
@ThinGuy
ThinGuy / pro-pkg-counter.sh
Created June 20, 2025 22:30
An Ubuntu Package Counter - Counts all vs installed and creates manifests by component for the current release.
#!/bin/bash
# An Ubuntu Package Counter - Counts all vs installed and creates manifests by component for the current release.
# Set message
export TITLE='\e[0;1;38;2;233;84;32mUbuntu Pro\e[0;1m™ Package Counter\e[0m'
export GBMSG="Thank you for using \e[0;1;38;2;233;84;32mUbuntu\x21"
# Parameters
export PROG="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/${BASH_SOURCE[0]##*/}"
export DARCH=$(dpkg --print-architecture)
@ThinGuy
ThinGuy / apt-manifest-maker.sh
Last active June 17, 2025 20:42
Create package manifests for all current LTS, Interim, and ESM Ubuntu releases
#!/bin/bash
export ARCH=amd64
export MDIR=~/manifests
[[ -f ${MDIR} ]] && { find ${MDIR} -type f -delete -o type d -delete; } || { mkdir -p ${MDIR}; }
declare -ag UBU_REL_SHORT=($(ubuntu-distro-info --supported-esm && ubuntu-distro-info --supported))
declare -ag UBU_REL_LONG=()
while IFS= read -r LINE;do
@ThinGuy
ThinGuy / aws-pro-counter.sh
Created June 5, 2025 16:07
Script to calculate all vs installed packages on Ubuntu
#!/bin/bash
# An Ubuntu Package Counter - Counts all vs installed and creates manifests by component for current release.
# Set parameters
export TITLE='AWS Summit Washington, DC 2025'
export PROG="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/${BASH_SOURCE[0]##*/}"
export DARCH=$(dpkg --print-architecture)
export REL=$(lsb_release -cs 2>/dev/null|sed 's/^.*$/\u&/')
export VER=$(lsb_release -rs 2>/dev/null)
[[ -f /etc/machine-id ]] && { export MID=$(cat /etc/machine-id); }
@ThinGuy
ThinGuy / pc.py
Created February 25, 2025 22:59
Protocol Checker
import requests
import ftplib
import subprocess
import socket
import argparse
import shutil
from urllib.parse import urlparse
def check_http_https(url):
"""Check if HTTP or HTTPS is available."""