Skip to content

Instantly share code, notes, and snippets.

@ThinGuy
ThinGuy / amt-check.sh
Created Jun 30, 2022
Check for AMT on NUC or other AMT-enabled PC
View amt-check.sh
amt-check() {
local G=https://github.com/mjg59/mei-amt-check.git
if [[ ! -f /srv/$(basename ${G%.*})/mei-amt-check ]];then
sudo chown -R $(id -un 1000):$(id -gn 1000) /srv
git clone ${G} /srv/$(basename ${G%.*})
cd /srv/$(basename ${G%.*})
make
fi
[[ -x /srv/$(basename ${G%.*})/mei-amt-check ]] && { sudo /srv/$(basename ${G%.*})/mei-amt-check; }
};export -f amt-check
@ThinGuy
ThinGuy / lxd-maas-microcloud-2022.sh
Created Jun 29, 2022
Updated lxd-maas microcloud
View lxd-maas-microcloud-2022.sh
#!/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 Jun 29, 2022
Download latest lxd-migrate
View get-lxd-migrate.sh
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 Jun 24, 2022
Disable / Enable ZFS auto-snapshots
View zfs-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 Jun 24, 2022
Install python-kasa on Ubuntu
View install-kasa.sh
#!/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 May 28, 2022
Add music to mikrotik routers
View mikrotik.beep.music.sh
/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 Apr 8, 2022
Metadata keys for AWS EC2
View aws-ec2_metadata.txt
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 Mar 28, 2022
Linux console rotation
View fbcon-show-rotation.sh
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 Mar 29, 2022
Configuring APT with Cloud-Init - Examples standard cloud-init (public cloud, MAAS, etc), Juju, and LXD.
View apt-cloud-init.yaml
#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 Jan 31, 2022
Create csv (or "p"sv in this case) from an htmltabl using htmltab
View htmltab.sh
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