scripts/README.md
Martin Matous bf67d3d463
readme: newline fix
Signed-off-by: Martin Matous <m@matous.dev>
2025-05-02 15:33:59 +02:00

4.2 KiB

Various useful-ish scripts

Scripts I wrote at some point or another. Inconsistent quality, no guarantees.

It's likely some never worked or that I got bored writing halfway.

availability-monitor.py

Low-budget homemade handmade monitoring for homeserver.

Status: active use

Dependencies: python3, apprise, cryptography, dnspython, requests, Matrix account

Usage: Use provided availability-monitor.service as user unit.

btrfs-scrub.py

Scrub btrfs volume and report results via matrix and e-mail.

Status: active use

Dependencies: python3, apprise, Matrix account

Usage: Invoke periodically using systemd timer (or cron).

dnf-search-install.py

Wrapper, marks already installed packages for dnf search.

Status: active use

Dependencies: dnf5, python3

Setup:

sudo cp ./dnf-search-installed.py /usr/local/bin/.
alias --save dnf '/usr/local/bin/dnf-search-installed.py'

Usage: dnf search <package>

ensure-port-fwd.py

Ensure given ports are present in TC7200 port forwarding table.

For all those who get shitty routers shoved down their throats by their greedy and incompetent ISPs who like to randomly reset their settings for fun and profit using a backdoor.

Status: active use (🖕 UPC/Vodafone)

Dependencies: selenium, geckodriver, e-waste

Usage: Run as a systemd service

gentoo-chroot.sh

Automate chrooting from live USB to fix installed system.

Status: active use :(

Dependencies: Nothing unusual

Usage: chroot.sh

gtokei.sh

Wrapper, count lines of code for git repos with tokei.

Status: active use

Dependencies: tokei, git

Usage: gtokei.sh https://github.com/some/repo

kernel-update.py

Automate chores when configuring, compiling and updating kernel.

Status: active use

Dependencies: dracut, Gentoo (not really but eselect, specific names and paths...)

This will update kernel using /usr/src/linux/.config to the latest installed sys-kernel/gentoo-sources.

Usage: kernel-update.py

Alt.: kernel-update.py <old-version> <new-version>

mail-payroll.py

Parse Thunderbird inbox in mailbox format, decrypt and save pdf attachments from selected sender.

Status: active use

Dependencies (python): pikepdf

Dependencies (systemd): python3, qpdf

Usage: Invoke when receiving new mail using systemd path monitoring.

njalla-tlsa-rotate.py

Perform 3 1 1 + 3 1 1 TLSA key rollover for Maddy mailserver with 3h window. Since the script is stateless and rebooting a machine would interfere, reboot is blocked via logind for the duration.

Status: active use

Dependencies (python): certbot, cryptography, dasbus Dependencies (system): caddy, maddy, python3, systemd

Usage: Invoke periodically using systemd timer.


flac-convert.py

Convert all .m4a into max-compressed .flac

Status: ancient one-off, likely low quality

Dependencies: ffmpeg

Usage: flac-convert.py /path/to/music

jxl-convert.py

Recursively convert jpgs to jxls with additional checks.

Status: one-off

Dependencies: libjxl

Usage: ./jxl-convert.py /path/to/pics

invoke-magic.bat

Add watermark to photo and create thumbnail. Contains detailed parameter explanation. Created for friend's blog.

Status: ancient but probably still working

Dependencies: imagemagick

Usage: Run next to logo.png and workdir directory with photos

prune-woodpecker.py

Prune Woodpecker CI's DB. Expects woodpecker.sqlite in the same directory. Useful for getting rid of a string of failed pipelines while setting things up.

Tested with Woodpecker 2.8.x and sqlite backend.

Status: one-off

Usage: ./prune-woodpecker.py <start> <stop>

sync-apparmor.py

Scan source directory of profiles and binaries in the system.

Copy profiles that have a corresponding binary from src to dst. Clean profiles that don't have a corresponding binary from dst.

Useful for initial profile dir setup and mopping up old profiles.

Doesn't work for subprofiles

Status: one-off

Dependencies: apparmor

Usage: sync-apparmor.py <src> <dst>

try-luks-from-kdbx.py

Retrieve known password for a LUKS volume from a KeePass DB.

For those moments when you forget the name of or mislabel your DB entry.

Status: one-off

Dependencies: pykeepass

Usage: try-luks-from-kdbx.py /path/to/kdbx /path/to/block-device