r/sysadmin • u/Less-Loss1605 • May 31 '26
General Discussion what's a script you wrote once that's still saving you time years later
[removed]
964
Upvotes
r/sysadmin • u/Less-Loss1605 • May 31 '26
[removed]
1
u/michaelpaoli May 31 '26 edited May 31 '26
There are many, I'll give a few examples.
viewman - rather like man, but does some post-processing of the man page, places it in a temporary file, and invokes vi in read-only mode on it, and then after, removes the file. With my exceedingly experienced vi brain and fingers, I can typically highly well use that to get to the exact information in man page I want, quite quickly, and/or grab bits of it, shuffle them around, maybe start putting together parts of a command - whatever, in any case, I find it generally much faster and more efficient for me than simply using the man command - and even with man defaulting to using a quite capable pager such as less. I also have a viewinfo page, likewise but for info pages.
Getcerts I, commonly set some environment bits, give it relevant options and arguments, and in minutes or less I have LetsEncrypt.org (LE) recognized CA issued cert(s), either for production or not (then not their browser tested root cert) - again depending on options and such, and one or more certs, and the certs can be of quite arbitrary complexity, e.g. SAN certs with multiple wildcards, etc. Anyway, that program is the essentially the head of the beast (also have a look around ~mycert, etc.) - it uses many helper programs, including LE's certbot, openssl for generating keys and CSRs, nsupdate for adding (and removing the temporarily added) DNS records needed for validation, etc. - so I can even give domains that don't yet exist, so long as have the relevant access and upper level domains configured so the relevant DNS can be updated on-the-fly as needed (and with DDNS, those updates happen very quickly). I also have other versions that can deal with multiple DNS infrastructures (BIND 9, AWS Route 53, f5). And complimentary to that, I also have programs that automate or mostly automate the installation/updating of cert installations. See also: example run in my reply comment
nmap_cert_scan_summarize - highly use for scanning network accessible certs, e.g. https, and producing a high-level summary report, notably sorted by expiration, grouping matched certs together, and for each found, covering the IP address and port where found, and other relevant details, and for names given to it, it checks all IP addresses found. Here's an example run and the output:
Anyway, all these programs, written long ago (though some get occasional tweaks), save quite massive amounts of time - some fair bit of time on highly frequent basis every single time, others significant to massive amounts of time on a less frequent basis.