Skip to content

Instantly share code, notes, and snippets.

View ThinGuy's full-sized avatar

craig bender ThinGuy

View GitHub Profile
@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 14, 2024 22:41
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'
@ThinGuy
ThinGuy / ubuntu-repo-size.bash
Created November 29, 2023 18:05
Get Ubuntu Repo Size - Non standard repos are a WIP
ubuntu-repo-size() {
ubuntu-repo-size_usage() {
printf "\n\e[1m\e[2G${FUNCNAME%%_*}\e[0m\n\n"
printf "\e[1m\e[2GUsage\e[0m: ${FUNCNAME%%_*} [options]\n\n"
printf "\e[1m\e[2GOptions\e[0m:\n\n"
printf "\e[3G -a, --arch \e[28GArchitecture to display, i.e. amd64,arm64,armhf,i386,ppc64el,s390x (Default: amd64)\n"
printf "\e[3G -s, --series \e[28GRelease nicknames to get information for, (Default: current LTS)\n"
printf "\e[3G -c, --components \e[28GList of repo components to query (Default: main,universe,multiverse,restricted)\n"
printf "\e[3G -p, --pockets \e[28GList of repo pockets components to query (Default: \$series \$series-updates \$series-backports \$series-security \$series-proposed)\n"
printf "\e[3G -i, --intel-repo-uri \e[28GURI of ubuntu archive for amd64/i386 (Default: http://archive.ubuntu.com/ubuntu/dists)\n"
@ThinGuy
ThinGuy / xrdp-install.sh
Last active February 11, 2024 02:19
Scripted XRDP Install with various fixes
#!/bin/bash
##############################
# Scripted XRDP Installation #
##############################
### Note: You can only be logged in via console or RDP, not both.
### If you get blackscreen via RDP or if console keeps going
### back to login screen, run `gnome-session-quit --force --logout`
### via ssh as the same user you are trying to login
sudo apt install \
gimp gimp-plugin-registry gimp-data-extras gimp-help-common gimp-help-en gimp-gap gimp-data -qyf \
$(apt-cache search -n '^obs-'|awk '/Studio|studio/&&!/websocket/{print $1}'|paste -sd' ') \
-yqf --auto-remove --purge
@ThinGuy
ThinGuy / fix-hydrapaper.sh
Created September 28, 2023 01:14
Fix thumbnail problems in Hydrapaper when on a python3-based system or when using Dark mode
#!/bin/bash
# Fix thumbnails (Long deprecated Image.ANTIALIAS finally removed in PIL 10.0.0)
sudo sed -i 's/Image.ANTIALIAS/Image.LANCZOS/g' /usr/lib/python3/dist-packages/hydrapaper/wallpaper_flowbox_item.py
# Fix merge issues when using Dark mode (known buy merging to a single wallpaper in dark mode)
sudo sed -i 's/ if set_dark else \x27picture-uri\x27//g' /usr/lib/python3/dist-packages/hydrapaper/wallpaper_merger.py
# Restart/Reload hydrapaper App