Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
lol no

Cameron Tod cam8001

💭
lol no
  • Wellington, New Zealand
View GitHub Profile
@cam8001
cam8001 / lg-soundbar-network.md
Last active Oct 7, 2020
Trying to figure out what a weird device on my network was - turns out it was my FIL's LG soundbar
View lg-soundbar-network.md

Trying to figure out what this thing is:

$ nmap -A -T4 -Pn 10.99.98.97 2>/dev/null                                                  

Starting Nmap 7.60 ( https://nmap.org ) at 2020-10-07 16:34 NZDT
Nmap scan report for 10.99.98.97
Host is up (0.0038s latency).
Not shown: 997 filtered ports
PORT      STATE SERVICE         VERSION
8008/tcp  open  http            Google Chromecast httpd
@cam8001
cam8001 / userdata.sh
Created Sep 30, 2020
AWS EC2 userdata for Unifi Controller on Ubuntu 16.04. Assumes Correto is installed and Ubiqiuiti repo is added
View userdata.sh
#!/bin/bash
echo "Updating Unifi..."
systemctl stop unifi
apt update
# Disable interactive prompts for the unifi installer
echo "unifi unifi/has_backup boolean true" | debconf-set-selections
DEBIAN_FRONTEND=noninteractive apt-get install --only-upgrade unifi
# Update the Unifi config for a system using Amazon Corretto instead of OpenJDK
curl https://gist.githubusercontent.com/cam8001/585bc721b25c80e185b83269fdb62e4a/raw/de847624ee14b89814c8c759e2559d7871d6c4ce/correto_unifi.sh > /usr/lib/unifi/bin/unifi.init
@cam8001
cam8001 / filter-iam-roles.sh
Created Sep 29, 2020
Filter IAM roles showing trust relationship, conditions, and principal
View filter-iam-roles.sh
aws iam list-roles | jq '.Roles | .[] | { role_name: .RoleName, action: .AssumeRolePolicyDocument.Statement | .[] | .Action, principal: .AssumeRolePolicyDocument.Statement | .[] | .Principal, condition: .AssumeRolePolicyDocument.Statement | .[] | .Condition }'
@cam8001
cam8001 / ubuntu-ssm-user-data.sh
Last active Sep 28, 2020
Ubuntu 16.04 AMI 20180627 and later user data for SSM session manager
View ubuntu-ssm-user-data.sh
#!/bin/bash
apt update && apt upgrade -y
ln -fs /usr/share/zoneinfo/Pacific/Auckland /etc/localtime
systemctl start snap.amazon-ssm-agent.amazon-ssm-agent.service
systemctl enable snap.amazon-ssm-agent.amazon-ssm-agent.service
@cam8001
cam8001 / init-version-systemd.md
Last active Sep 19, 2020
/sbin/init: unrecognized option '--version'
View init-version-systemd.md

If you get an error in some script or whatever like:

/sbin/init: unrecognized option '--version'

This is probably because:

  • /sbin/init is a symlink to /lib/systemd/systemd
  • systemd supports the --version flag, but not if it is called via a symlink ??

So, if possible, replace calls to /sbin/init with calls to systemd instead. Or something

@cam8001
cam8001 / amazon.url
Created Sep 9, 2020
Example .url file, filesystem link which opens in browser
View amazon.url
[InternetShortcut]
URL=https://www.amazon.com/
View guardutyToSlack.js
'use strict';
/**
* Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: MIT-0
*/
const AWS = require('aws-sdk');
const url = require('url');
const https = require('https');
@cam8001
cam8001 / acm_arn_regex.ts
Last active May 8, 2020
Regex to validate an AWS Certificate Manager (ACM) certification ARN
View acm_arn_regex.ts
// Standalone utility function for checking whether a certificate ARN is valid.
const isValidCertArn = (arnString: string): boolean => {
return /arn:(aws[a-zA-Z-]*)?:acm:[a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1}:\d{12}:certificate\/[a-zA-Z0-9-_]+/.test(
arnString
);
};
@cam8001
cam8001 / correto_unifi.sh
Last active Sep 30, 2020
Corrretto JAVA_HOME on Ubuntu 16.04. Replace /etc/init.d/unifi with this!
View correto_unifi.sh
#!/bin/bash
#
# /etc/init.d/UniFi -- startup script for Ubiquiti UniFi
#
#
### BEGIN INIT INFO
# Provides: unifi
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
@cam8001
cam8001 / ubuntu-allocate-eip-on-launch.sh
Last active Mar 18, 2020
EC2 User Data script to allocate an EIP on launch.
View ubuntu-allocate-eip-on-launch.sh
#!/bin/bash
#
# Associate a given elastic IP with an instance on boot.
#
# Useful in autoscaling groups with a max-size of 1, where you always want the
# same IP for a given instance.
#
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
AWS_DEFAULT_REGION=ap-southeast-2
You can’t perform that action at this time.