Skip to content

Instantly share code, notes, and snippets.

@rjhornsby
rjhornsby / install.ps1
Created March 14, 2023 17:32
modified cinc install.ps1 for proxy auth
new-module -name Omnitruck -scriptblock {
[Console]::OutputEncoding = New-Object -typename System.Text.ASCIIEncoding
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'
function Get-PlatformVersion {
switch -regex ((Get-Win32OS).version) {
'10\.0\.\d+' {$platform_version = '2016'}
'10\.0\.17\d+' {$platform_version = '2019'}
'6\.3\.\d+' {$platform_version = '2012r2'}
'6\.2\.\d+' {$platform_version = '2012'}
# do all the same stuff as the linux script, but do it stupider.
#
# powershell
## Bootstrap a windows node to sev1 chef
# Requirements:
# - A validator key must be present on the target node at `c:/cinc/validator.pem`
# Your key can be found at by going to your vault /client/<your_client_id>/secret/chef/chef-server/validator"
#
# Usage:
# Copy this script to your target and run it like so:
@rjhornsby
rjhornsby / kitchen-passwd.py
Created March 9, 2023 20:37
kitchen windows password
#!/usr/local/bin/python3
import clipboard as c
import os
import sys
import yaml
base_path = f"{os.getcwd()}/.kitchen"
files = [os.path.join(base_path, file) for file in os.listdir(base_path) if (file.lower().endswith('.yml'))]
files.sort(key=os.path.getmtime)
@rjhornsby
rjhornsby / berks_preflight_check.sh
Created May 14, 2021 19:01
Compare local cookbook versions to Chef server versions before `berks upload`
#!/bin/zsh
TMPDIR=$(mktemp -d)
# check for gsed usage
if [ "$(uname)" = "Darwin" ]; then
if [ ! -x "/usr/local/bin/gsed" ]; then
echo "macOS platform detected, but gsed not found. Please install it."
exit 1
fi
@rjhornsby
rjhornsby / pi_init.sh
Last active August 8, 2021 05:21
RaspberryPi after-first-boot config shell script
#!/bin/bash
# If you wish to have the pi change its default hostname from 'raspberrypi',
# pass the new hostname as an argument, ie:
# /boot/init.sh urmomspi
# Change these values for your environment, or set them to empty strings
# to leave at the default
LOCALE="en_US.UTF-8"
KEYB_LAYOUT="us"
@rjhornsby
rjhornsby / macos-mount-iso.md
Last active February 27, 2021 17:59
Mount ISO in MacOS

Credit: https://unix.stackexchange.com/questions/298685/can-a-mac-mount-a-debian-install-cd

This is one of those "I have to do this occasionally and can never remember how" things - mounting an ISO in macOS, especially Linux ISOs.

macOS has a few things that are stupid. Trying to mount a .iso file directly using normal means ends in failure:

hdiutil: mount failed - no mountable file systems

It's completely doable, unlike other image formats (.img, .dmg, etc), just takes a bit more effort.

@rjhornsby
rjhornsby / show-dhcp-leases.sh
Last active April 16, 2023 05:46
Show EdgeOS DHCP lease table
#!/bin/bash
# Quickly show the Ubiquity EdgeOS (ie EdgeRouter Lite)
# DHCP leases to identify devices (ie headless raspberrypi)
# without having to go through the EdgeOS web UI.
#
# Thanks to @matthew1471 for API docs
# https://github.com/matthew1471/EdgeOS-API
# requires jq - `brew install jq` on macOS
#!/bin/bash
echo "waiting for input"
read a
echo "value of a: $a"
echo "done."
== constructing a dog ==
== constructing an animal ==
Pets rendered as JSON:
[{"json_class":"Dog","data":{"has_fur":true,"color":"black","name":"fido","bark":"loud"}}]
=== Recovering lost pets from the evil JSON Deville ===
Calling Dog::json_create
{"json_class"=>"Dog",
"data"=>{"has_fur"=>true, "color"=>"black", "name"=>"fido", "bark"=>"loud"}}
== constructing a dog ==
$ ./shelter.rb
== constructing a dog ==
== constructing an animal ==
Pets rendered as JSON:
[{"json_class":"Dog","data":{"has_fur":true,"color":"black","name":"fido","bark":"loud"}}]
=== Recovering lost pets from the evil JSON Deville ===
Calling Dog::json_create
{"json_class"=>"Dog",
"data"=>{"has_fur"=>true, "color"=>"black", "name"=>"fido", "bark"=>"loud"}}