Skip to content

Instantly share code, notes, and snippets.

View ThinGuy's full-sized avatar

craig bender ThinGuy

View GitHub Profile
@ThinGuy
ThinGuy / lxd-maas-microcloud-2022.sh
Created June 29, 2022 19:26
Updated lxd-maas microcloud
#!/usr/bin/env bash
# vim: set et ts=2 sw=2 filetype=bash :
[[ $_ != $0 ]] || { printf "\n\e[2G\e[1mPlease source this script!\e[0m ( e.g. \"source ${BASH_SOURCE[0]}\" )\n\n"; sleep 1;exit; }
maas-microcloud-lxd() {
[[ -n ${FDEBUG} && ${FDEBUG} = true ]] && { set -x &>/dev/null; }
local DESC="${FUNCNAME}: Deploy a LXD Cluster via MAAS command line"
local CI_TZ='America/Los_Angeles'
local CI_LC='en_US.UTF-8'
local CI_TC=${CI_LC:3:2}
@ThinGuy
ThinGuy / get-lxd-migrate.sh
Created June 29, 2022 00:03
Download latest lxd-migrate
sudo wget -qO /usr/local/lxd-migrate --show-progress --progress=bar:force:noscroll $(curl -sSlL https://github.com/lxc/lxd/releases/latest|awk -F'"' '/href.*lxd-migrate/{print "https://github.com"$2}')
sudo chmod +x /usr/local/bin/lxd-migrate
@ThinGuy
ThinGuy / zfs-snapshots
Created June 24, 2022 22:56
Disable / Enable ZFS auto-snapshots
zfs-disable-snapshots() {
systemctl --user stop zsys-user-savestate.timer
systemctl --user disable zsys-user-savestate.timer
sudo mv /etc/apt/apt.conf.d/90_zsys_system_autosnapshot /etc/apt/apt.conf.d/90_zsys_system_autosnapshot.disabled
};export -f zfs-disable-snapshots
zfs-enable-snapshots() {
systemctl --user start zsys-user-savestate.timer
systemctl --user enable zsys-user-savestate.timer
@ThinGuy
ThinGuy / install-kasa.sh
Created June 24, 2022 22:49
Install python-kasa on Ubuntu
#!/bin/bash
declare -ag KASA_PKG_LIST=();
for i in python3.10-venv build-essential python3 python3-pip python3-poetry python3-cachecontrol python3-argcomplete python3-all-dev python3-wheel python3-setuptools python-all-dev python-setuptools python3.10-venv python3-virtualenv;do
[[ $(dpkg -l $i|awk '/'${i}'/{print $1}') = ii ]] && { true; } || { PKG_LIST+=("${i}"); };
done
[[ ${#KASA_PKG_LIST[@]} -ge 1 ]] && { sudo apt install ${KASA_PKG_LIST[@]} -yqf --auto-remove --purge -o Acquire::ForceIPv4=true; } || { true;printf "\n\nAll package dependencies already installed\x21\n\n"; }
python3 -m pip install --user --upgrade pip
python3 -m pip install --user virtualenv
python3 -m pip install --user python-kasa --pre
@ThinGuy
ThinGuy / mikrotik.beep.music.sh
Last active January 24, 2025 13:54
Add music to mikrotik routers
/system script add dont-require-permissions=no name="Super=Mario-Bros" owner=admin policy=read source=":beep frequency=660 length=100ms;\n:delay 150ms;\n:beep frequency=660 length=100ms;\n:delay 300ms;\n:beep frequency=660 length=100ms;\n:delay 300ms;\n:beep frequency=510 length=100ms;\n:delay 100ms;\n:beep frequency=660 length=100ms;\n:delay 300ms;\n:beep frequency=770 length=100ms;\n:delay 550ms;\n:beep frequency=380 length=100ms;"
/system script add dont-require-permissions=no name="Thunderstruck" owner=admin policy=read source=":local n11 63,66;\n:local n12 64,67;\n:local n21 71,69,68,69,68,66,68,64,66,63;\n:local n22 64,63;\n \n:local n11 (\$n11,\$n11);\n:local n12 (\$n12,\$n12);\n:local n1 (\$n11,\$n11,\$n12,\$n12);\n:local n2 (\$n21,\$n22,\$n22,\$n22);\n:local notes (\$n1,\$n1,\$n2,\$n2);\n \n:local ticks 2;\n:local speed 55ms;\n:local stacc 5ms;\n# Transposition \n:local transpose -48;\n# ============================== \n# Don't change this: \n:local frqtab 8372,8869,9397,9956,10548,11175,11839,12543
@ThinGuy
ThinGuy / aws-ec2_metadata.txt
Created April 8, 2022 00:37
Metadata keys for AWS EC2
block-device-mapping/ami
block-device-mapping/ebsN
block-device-mapping/ephemeralN
block-device-mapping/root
block-device-mapping/swap
elastic-gpus/associations/elastic-gpu-id
elastic-inference/associations/eia-id
events/maintenance/history
events/maintenance/scheduled
events/recommendations/rebalance
@ThinGuy
ThinGuy / fbcon-show-rotation.sh
Created March 28, 2022 16:55
Linux console rotation
fbcon-show-rotation() {
(clear;printf "\n\nfbcon=rotate:0\t\tfbcon=rotate:1\tfbcon=rotate:2\t\tfbcon=rotate:3\n";(printf "\\u256D\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500T\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u256E\t\\u256D\\u2500\\u2500\\u2500R\\u2500\\u2500\\u2500\\u256E\t\\u256D\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500B\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u256E\t\\u256D\\u2500\\u2500\\u2500L\\u2500\\u2500\\u2500\\u256E\n"; printf "\\u2502\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u2502\t\\u2502\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u2502\t\\u2502\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u2502\t\\u2502\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u2502\n"; printf "L\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\u200AR\t\\u2502\\u200A\\u200A\\u200A\\u200A\\u200A\\u200A\\
@ThinGuy
ThinGuy / apt-cloud-init.yaml
Last active March 29, 2022 23:04
Configuring APT with Cloud-Init - Examples standard cloud-init (public cloud, MAAS, etc), Juju, and LXD.
#cloud-config
## Writing out any credentials for private ppa access. If you need this configured early, use a bootcmd
## If can wait until the target environment is available, use a write_files:
bootcmd:
- ['cloud-init-per', 'once', 'apt1', 'echo', 'bWFjaGluZSBwcml2YXRlLXBwYS5sYXVuY2hwYWQubmV0L2Nhbm9uaWNhbC1rZXJuZWwtcnQvcmVsZWFzZS91YnVudHUgbG9naW4gamFuZS11c2VyIHBhc3N3b3JkICA2UFBSNzRwcU9SWElqc3JJczhBVwptYWNoaW5lIHByaXZhdGUtcHBhLmxhdW5jaHBhZC5uZXQvY2Fub25pY2FsLWtlcm5lbC1ydC9wcm9wb3NlZC91YnVudHUgbG9naW4gamFuZS11c2VyIHBhc3N3b3JkICBCRnBNc0RXZjVtV1lzU3cxUExRYwptYWNoaW5lIHByaXZhdGUtcHBhLmxhdW5jaHBhZC5uZXQvY3Jicy9zdGFibGUvdWJ1bnR1IGxvZ2luIGphbmUtdXNlciBwYXNzd29yZCAgUWZramZWWWNSSTVkR3VWYlhJb2gKbWFjaGluZSBwcml2YXRlLXBwYS5sYXVuY2hwYWQubmV0L3VidW50dS1hZHZhbnRhZ2Uvc2VjdXJpdHktYmVuY2htYXJrcy91YnVudHUgbG9naW4gamFuZS11c2VyIHBhc3N3b3JkICBhb3hMNHZlR0RGU1kwaGpWUUhHSAptYWNoaW5lIHByaXZhdGUtcHBhLmxhdW5jaHBhZC5uZXQvY3Jicy9zdGFibGUvdWJ1bnR1IGxvZ2luIGphbmUtdXNlciBwYXNzd29yZCAgdTBRRTNHTXZpR2RqTnB2NEx3aHUKbWFjaGluZSBwcml2YXRlLXBwYS5s
@ThinGuy
ThinGuy / htmltab.sh
Created January 31, 2022 02:44
Create csv (or "p"sv in this case) from an htmltabl using htmltab
sudo apt install pipx -yq
pipx install git+https://github.com/flother/htmltab
# Too many commas in table to make a CSV. Cleanup output and use pipes as the delimiter
(htmltab https://linux.dell.com/repo/community/openmanage|sed 's/,"|/|"/g;s/),"/)|/g;s/","/|/g;1s/,/|/g;s/,,/|/g;s/LTS,/LTS|/g;s/),v/)|v/g;s/),N/)|N/g;s/,\r$/|/g;s/(/ (/g')|tee ~/dell.psv
@ThinGuy
ThinGuy / dnsmasq.conf
Created January 30, 2022 01:00 — forked from j4zzcat/dnsmasq.conf
Preseed file for network console installation, ubuntu 19.10
interface=eth1
bind-interfaces
domain=pxe.local
dhcp-range=eth1,192.168.100.51,192.168.100.55,255.255.255.0,8h
dhcp-option=3,192.168.100.2 # gateway
dhcp-option=6,192.168.100.2 # dns
enable-tftp
tftp-root=/srv/tftp
dhcp-vendorclass=BIOS,PXEClient:Arch:00000
dhcp-vendorclass=UEFI32,PXEClient:Arch:00006