Skip to content

Instantly share code, notes, and snippets.

View afresh1's full-sized avatar

Andrew Hewus Fresh afresh1

View GitHub Profile
@afresh1
afresh1 / oget
Last active December 13, 2020 01:10
Helper to download OpenBSD dist files (mostly bsd.rd) and verify them with signify.
#!/usr/bin/perl -T
use v5.16;
use warnings;
delete $ENV{PATH};
delete $ENV{ENV};
use OpenBSD::Unveil;
use OpenBSD::Pledge;
@afresh1
afresh1 / vfs-sysctl_hw_sensors-discovery
Created July 22, 2020 00:51
A perl script to convert OpenBSD's `sysctl hw.sensors` output into something that might be useful for Zabbix.
#!/usr/bin/perl -T
use v5.16;
use warnings;
use OpenBSD::Pledge qw< pledge >;
use JSON::PP qw<>;
# Copyright (c) 2020 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / openbsd-httpd-fastcgi-notes.md
Created July 12, 2020 21:26
Notes on how OpenBSD's httpd handles its FastCGI parameters. Debugging it with slowcgi.

These examples all live in a default server block in your httpd.conf(5).

server "default" {
	listen on * port 80
	... # all the location blocks can together right here
}

We'll be using slowcgi(8) as the example, because with the -d flag it helpfully spits out the FastCGI environment it got from httpd(8) and what it's planning to do with that.

@afresh1
afresh1 / fill-chroot.sh
Last active December 22, 2021 22:14
fill-chroot - Add files and their needed libs to a chroot directory
#!/bin/sh
chroot=/var/www # ${PWD}
copy_recurse() {
file=$1
[ -e "${chroot}${file}" ] && return
mkdir -p $( dirname "${chroot}${file}" )
cp -p "$file" "${chroot}${file}"
@afresh1
afresh1 / teetime
Last active December 22, 2021 22:14
A perl implementation of "tee" that prefixes each line to the teed file with a timestamp relative to the start of ths script.
#!/usr/bin/perl
use strict;
use warnings;
use v5.10;
use Time::HiRes qw< gettimeofday tv_interval >;
# Copyright (c) 2020 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / 6rd_config.sh
Last active December 7, 2019 02:38
Calculates a 6rd IP and default gateway and outputs them in an OpenBSD hostname.gif0 format from an IPv4 address, with optional mask, the v4 destination, a 6rd prefix with length. See also this gist: https://gist.github.com/afresh1/791343380b4410687d51fdd94f20bd42
#!/bin/ksh
set -e
set -f -u -C
# Copyright (c) 2019 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
@afresh1
afresh1 / HTTP-Tiny-nc.pm
Last active May 2, 2023 23:56
A monkey patch to let perl's HTTP::Tiny to use the OpenBSD netcat with TLS support to access https sites without installing IO::Socket::SSL and Net::SSLeay.
use v5.16;
use warnings;
package HTTP::Tiny::nc;
use parent 'HTTP::Tiny';
our $VERSION = v0.0.3;
# Copyright (c) 2019-2023 Andrew Hewus Fresh <afresh1@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / Installing_an_OpenBSD_VM_under_FreeNAS.md
Last active May 4, 2022 02:32
Installing OpenBSD in a bhyve VM under FreeNAS
@afresh1
afresh1 / force_hires_move.pl
Created November 3, 2017 14:39
Forces File::Copy to use HiRes times in move.
#!/usr/bin/perl
use v5.20;;
use warnings;
BEGIN {
require Time::HiRes;
# Has to come before importing File::Copy
Time::HiRes->export( 'File::Copy', qw( stat utime ) );
}
use File::Copy;
#!/usr/bin/env plackup
use strict;
use warnings;
use Plack::Builder;
use Plack::App::File;
use Plack::App::WrapCGI;
BEGIN {
chdir "/var/www/blogsum" or die "Unable to chdir: $!";