Skip to content

Instantly share code, notes, and snippets.

View sshimko's full-sized avatar

Spencer Shimko sshimko

View GitHub Profile
@sshimko
sshimko / snmpd.conf
Created July 30, 2021 16:00
snmpd.com for MacOS with extend for distro, serial, hardware, and manufacturer.
# Sort out your own auth.
com2sec mynetwork 192.168.0.1/24 COMMUNITYNAME
rocommunity COMMUNITYNAME default .1
syscontact My Name <[email protected]>
syslocation Judecca
# LibreNMS had some example extends for Linux so I put these together for macOS.
extend distro /bin/bash -c '/usr/bin/sw_vers|grep -v Build|sed -e "s/^.*:.//"|tr "\\n" " "'
# This gives a pretty name, but a pretty name isn't always available in a system-wide place and pointing into /Users/ somewhere is bad.
@sshimko
sshimko / govcloud-ips.sh
Last active October 27, 2021 19:55
Current AWS GovCloud IPs - useful for firewall (letting them in or keeping them out)
#!/bin/sh
# Fetch current govcloud IP ranges
/usr/bin/curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '[.prefixes]|.[]|.[] | select(.region|test("us-gov")) | .ip_prefix| gsub("\""; "")'
@sshimko
sshimko / network
Created May 15, 2022 17:50
Libvirt Allow New to Guests
#!/bin/bash
# libvirt is rude and clobbers rules but lets us hook in via /etc/libvirt/hooks/network, update the IP and NIC if you need to.
# This adds a simple rule to accept NEW incoming packets on a host so a guest (or perhaps something like a UPNP daemon on the host) can determine what comes and goes
# What is looks like before:
# ACCEPT all -- * virbr0 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
# REJECT all -- * virbr0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
# What it looks like after
# ACCEPT all -- * virbr0 0.0.0.0/0 192.168.122.0/24 state NEW
# ACCEPT all -- * virbr0 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
# REJECT all -- * virbr0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
@sshimko
sshimko / build_kmod_rhel.sh
Last active July 11, 2022 21:54
Build in-tree kernel module for RHEL
#!/bin/bash
# Builds a module that is present in the kernel sources but not built and shipped by Red Hat.
# For me, this was a 5Gbps USB NIC needing the aqc111 module (not atlantic) on RHEL 8.
#
# It grabs the kernel src RPM based on the latest you have installed
# This might be a lot easier in DKMS.
MODULE="aqc111"
MODULE_KPATH="drivers/net/usb"
MODULE_KCONF="CONFIG_USB_NET_AQC111"
@sshimko
sshimko / check_ring_sensors_tts.yaml
Created January 30, 2023 00:53
Home Assistant Script: Check for faulted Ring contact sensors and identify them through a media player
alias: Speak Faulted Alarm Sensors Script
description: ""
sequence:
- service: tts.cloud_say
data:
entity_id: media_player.office_sonos
message: >
{% set lst = states.binary_sensor |
rejectattr('attributes.device_class', 'undefined') |
selectattr('entity_id', 'in', integration_entities('mqtt')) |