Scripts

Script: Update Linode DNS Records with WAN IPs (Dynamic DNS)

Either of these scripts will grab both the IPv4 and IPv6 (if any) addresses assigned to any WAN I’m behind, and, using Linode’s DNS API, will update my DNS records with same and log changes/errors using logger. In effect, it’s a homemade Dynamic DNS updater. Linode’s developing a new API so that’s why two versions exist. Download from Bitbucket To use the script, you need: A Linode API key (for version 3 of Linode’s DNS API) or Personal Access Token (for version 4 of Linode’s DNS API), the domain ID, and the resource (called record in v4) IDs of the DNS records you want to update.

One-Liners

#Handy One-Liners This page is a collection of random one-liners I’ve used and wanted to keep track of. list contents of all crontabs for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done

Script: Assemble NGINX Configuration Files

merge-ngx-conf.pl is a perl script used to assemble a set of nginx configuration files for one site. It has a number of options. See the bitbucket page or the help documentation in the script itself. In its simplest form, it’s called by issuing this command: merge-ngx-conf.pl /path/sites-available/filename The output is an assembled nginx configuration file with all the includes inserted. Using nginx.conf and domain.conf (or just domain.conf depending on the options selected), the script iterates through the include directives in the files and inserts the text from the referenced file.

Script: Parse Mail Headers

Here’s a perl script I put together that uses Email::Simple to extract the headers from a message. See link below. I’m using it to examine spam. It parses all the headers, with a focus on the Received headers. It should be easy to alter it to examine any header you want. As it is currently written, it: finds all the Received headers finds the first Received header that was added to the mail (presumably the header added by the first MTA that received it) extracts the IP from that header does an rDNS lookup if there’s a hostname, it looks up the nameservers for the base domain.