Skip to content

Instantly share code, notes, and snippets.

View afresh1's full-sized avatar

Andrew Hewus Fresh afresh1

View GitHub Profile
@afresh1
afresh1 / unifi.sh
Last active January 11, 2018 18:52
Command-line interface for the OpenBSD Ubiquiti [unifi port](http://ports.su/net/unifi)
#!/bin/sh
basename $0 |&
IFS=- read -p name cmd
if [ -z "$cmd" -a $# -gt 0 ]; then
cmd=$1
shift
fi
cmd=${cmd%svc}
@afresh1
afresh1 / get_dns_blacklists.sh
Last active June 12, 2018 19:55 — forked from tvlooy/get_dns_blacklists.sh
Block ads by DNS
#!/bin/sh
# "include: /var/unbound/etc/ad-blacklist.conf" in /var/unbound/etc/unbound.conf
# run script as daily cron
TMPFILE=$( mktemp get_dns_blacklists-XXXXXXXXX )
trap 'rm -f $TMPFILE; exit 1' EXIT KILL INT QUIT TERM
(
ftp -VM -o- https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts | grep ^0.0.0.0 | awk '{ print $2 }'
@afresh1
afresh1 / find_networks.sh
Last active July 16, 2018 14:30
A script to find and connect to known wifi networks on OpenBSD. Works for me on my iwn card in my laptop
#!/bin/sh
# find_network.sh - An OpenBSD Wireless Network configurator
# Looks for available networks listed at the end of the script
# Use this by adding "!/path/to/find_network.sh \$if" to your wlan hostname.if
if=$1
if [ -z "$if" ]; then
echo "Usage: $0 interface" >&2
exit 2;
fi
@afresh1
afresh1 / drop_privileges_fcgi_app.psgi
Last active July 25, 2019 03:16
This is a proof of concept for an FCGI::ProcManager that will chroot into a directory and drop privileges for each child process.
#!/usr/bin/env plackup -s FCGIDropPrivs
use strict;
use warnings;
my ($user, $group) = qw( nobody nogroup );
my $uid = getpwnam($user);
my $gid = getgrnam($group);
my $root = '/var/empty';
package Plack::Handler::FCGIDropPrivs;
@afresh1
afresh1 / plenv-install-latest.sh
Last active September 19, 2019 19:12
Installs or upgrades to the latest perl5 version for each major release, as well as the latest development version.
https://github.com/afresh1/dotfiles/blob/master/plenv/libexec/plenv-install-latest
@afresh1
afresh1 / plenv-install-latest.sh
Last active September 19, 2019 19:13
Installs the latest available of each release version of perl plus the latest development version with https://github.com/tokuhirom/plenv
https://github.com/afresh1/dotfiles/blob/master/plenv/libexec/plenv-install-latest
@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 / start_inet6.sh
Last active May 8, 2020 17:24
Find the default IPv6 gateway and start forwarding traffic on OpenBSD and Comcast (XFinity)
#!/bin/sh
egress=$1
internal=$2
# This should set up ipv6 on XFinity or Comcast on OpenBSD 6.1
# Stop everything
/usr/bin/pkill dhcp6c
route -qn delete -inet6 default
ifconfig $egress -inet6
@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 / 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;