Skip to content

Instantly share code, notes, and snippets.

View ThinGuy's full-sized avatar

craig bender ThinGuy

View GitHub Profile
@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."""
@ThinGuy
ThinGuy / zscaler.sh
Created February 24, 2025 21:53 — forked from CalvinHartwell/zscaler.sh
Zscaler Proxy Example Script for Ubuntu + GNOME including CA Certificate import to browser trust store for Chrome/FF
#!/bin/bash
# Some of these files are uploaded to Landscape server
PAC_FILE_LOCATION="http://<zscaler-pac-config-file-location/file.PAC"
CA_TAR="zscaler.tar.gz"
CA_CERTIFICATE_NAME="<zscaler-root-ca-certificate-name-replace-me.crt>"
CERT_DIR_PATH="/usr/local/share/ca-certificates"
# Import ZSCALER Public CA Root Cert
sudo apt-get install libnss3-tools -y
@ThinGuy
ThinGuy / microcloud-base.yaml
Created January 30, 2025 16:08
One Box Microcloud - Nesting a Microcloud under LXD
name: microcloud-base
description: MicroCloud Base VM Profile
config:
boot.autostart: "true"
linux.kernel_modules: br_netfilter
user.network-config: |
renderer: networkd
version: 2
ethernets:
enp5s0: {}
@ThinGuy
ThinGuy / maas-files.nd
Created December 4, 2024 22:53
How to grab MAAS boot and deployment files
### **Variables**
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}'
``
@ThinGuy
ThinGuy / msdhcp-maas.md
Created November 14, 2024 18:07
How to Configure Microsoft DHCP for Canonical MAAS

How to Configure Microsoft DHCP for Canonical MAAS

This guide explains how to configure an external Microsoft DHCP server to work with Canonical MAAS (Metal as a Service). Configuring the right DHCP options will ensure that nodes are able to correctly PXE boot and communicate with MAAS for provisioning.

Step 1: Open the DHCP Management Console

  1. On your Windows Server, press Windows + R, type dhcpmgmt.msc, and press Enter.
  2. Alternatively, you can access it through Server Manager by selecting Tools -> DHCP.

Step 2: Select the DHCP Scope to Configure

  1. In the DHCP console, navigate to the appropriate scope that you want to configure for MAAS nodes.
@ThinGuy
ThinGuy / add-arch-2-new-sources.sh
Last active October 3, 2024 12:40
Fix apt architecture error messages: "...doesn't support architecture 'i386'"
# To prevent unsuppoorted architecture error messages from apt on Ubuntu 24.04 (Noble Numbat)
# with the new apt sources format
# Example error messages on `apt update` after a fresh install:
# N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://packages.microsoft.com/repos/edge stable InRelease' doesn't support architecture 'i386'
# N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://dl.google.com/linux/chrome/deb stable InRelease' doesn't support architecture 'i386'
#################################################
### SINGLE-ARCH (i.e. fix arch-related error) ###
#################################################
@ThinGuy
ThinGuy / maas-build-debug-image.bash
Created March 20, 2024 03:30
Updated MAAS debug image, adds password for the root user in case of a bad networking configuration that results in the node being deployed is unable to contact the MAAS server to get its metadata.
maas-build-debug-image() {
local -a UBU_RELS=(bionic)
export IMG_PWD="Ubuntu1+"
# Create salted pw for images
printf "\e[2G - Salting the desired password of \x22${IMG_PWD}\x22 for use in debug-image\n"
export SALTED_PWD="$(echo 'Ubuntu1+'|mkpasswd --method=SHA-512 --rounds=4096 -s)"
# Dowload images
printf '%s\n' ${UBU_RELS[@]}|xargs -rn1 -P0 bash -c '
IMG_URL=https://cloud-images.ubuntu.com/${0}/current/${0}-server-cloudimg-amd64-root.tar.xz;
printf "\e[2G - Fetching Ubuntu release ${0^} from ${IMG_URL}\n"
@ThinGuy
ThinGuy / networkd-disable-offload.sh
Last active February 16, 2025 13:25
systemd-networkd script to disable TSO, GSO, and GRO on all NICs reporting up
#!/bin/bash
sudo install -o0 -g0 -m0755 /dev/null /etc/networkd-dispatcher/routable.d/99-disable-tso-gso-gro.sh
cat <<'EOF' |sudo tee /etc/networkd-dispatcher/routable.d/99-disable-tso-gso-gro.sh
#!/bin/bash
#
# This script will be placed in /etc/networkd-dispatcher/routable.d/
# and made exectuable
#
@ThinGuy
ThinGuy / gecos-passwd.sh
Created January 31, 2024 04:29
Fix: BAD PASSWORD: The password contains the user name in some form.
# Work around for when you want/need your password to contain part of your username
# Disable the pwquality profile in PAM
sudo pam-auth-update --disable pwquality
# Change your password
echo 'ubuntu:Ubuntu123!'|sudo chpasswd -s
# Enable the pwquality profile in PAM
sudo pam-auth-update --enable pwqualit
@ThinGuy
ThinGuy / fix-usb2serial.sh
Last active May 3, 2024 17:07
Function create UDEV rules for all USB to Serial Devices so that apps such as minicom, screen, gtkterm can access device as normal user
fix-usb2serial() {
printf "\n\e[1mFix USB to Serial device permissions\e[0m\n"
local DEVREGX='.*tty[UA].*' W='s'
declare -ag TTYUSB_DEVS=($(find /sys/class/tty -type l -regex "${DEVREGX}" -printf "%P\n" 2>&1))
[[ ${#TTYUSB_DEVS[@]} -ge 1 ]] && { local W=""; } || { printf "\nNo USB to Serial devices found using regex \x22${DEVREGX}\x22.\nQuitting\n\n";return 3; }
[[ -n $(id -Gn|grep 2>/dev/null -oE dialout) ]] && { printf "\e[2G - User $USER already a member of \x22dialout\x22 group \e[3m(Good\x21)\e[0m\n"; } || { printf "\e[2G -- Adding User $USER to the \x22dialout\x22 group\n"; sudo usermode -aG dialout $USER; }
printf "\e[2G - Creaing udev rules file: /etc/udev/rules.d/50-ttyUSB.rules\n"
sudo install -o0 -g0 -m0644 /dev/null /etc/udev/rules.d/50-ttyUSB.rules
printf "\e[2G - Adding ${#TTYUSB_DEVS[@]} udev rule${W}:\n"
(printf "%s\n" ${TTYUSB_DEVS[@]}|xargs -I{} printf "KERNEL==\x22{}\x22,\x20MODE=\x270666\x22\n")|sudo tee -a /etc/udev/rules.d/50-ttyUSB.rules|sed -r 's/^/ /g'