Skip to content

Instantly share code, notes, and snippets.

Avatar

John Place UnixSage

View GitHub Profile
@UnixSage
UnixSage / selectiveDump.sh
Created Jul 30, 2021
Shell script that calls dump with an exclude list
View selectiveDump.sh
#!/bin/sh
if [ $# = 2 ] ; then
NODENAME=$1
LEVEL=$2
elif [ $# = 1 ] ; then
NODENAME=$HOSTNAME
LEVEL=$1
else
NODENAME=$HOSTNAME
@UnixSage
UnixSage / CertBotGoDaddyAuthHook.sh
Last active May 8, 2021
Script to use with CertBot's --manual-auth-hook switch
View CertBotGoDaddyAuthHook.sh
#!/bin/sh
KEY="GoDaddyAuthKey"
SECRET="GoDaddySecret"
APISITE="api.godaddy.com"
BASEDOMAIN=`echo ${CERTBOT_DOMAIN} | awk -F. '{OFS="."; print $(NF-1),$(NF)}'`
SUBDOMAIN=`echo ${CERTBOT_DOMAIN} | sed -e 's/'${BASEDOMAIN}'//' -e 's/\.$//'`
@UnixSage
UnixSage / CertBotNearlyFreeSpeechAuthHook.sh
Last active May 8, 2021
Drop in script for CertBot's --manual-auth-hook switch for DNS Hosted at NearlyFreeSpeech.com
View CertBotNearlyFreeSpeechAuthHook.sh
#!/bin/bash
API_KEY="##NFS-API-KEY##"
LOGIN="##NFS-USER##"
updatedns() {
OLDDATA=`dig @${NAMESERVER} -t txt +noall +answer ${DNSRECORD}.${CERTBOT_DOMAIN} | awk '{gsub("\"",""); print $5}'`
for FUNCTION in removeRR addRR ; do
echo "Running ${FUNCTION}"
@UnixSage
UnixSage / PurgeOrphanedPacker.py
Created Apr 15, 2021
AWS Lambda function that will stop and eventually terminate instances that have packer keys attached to them .
View PurgeOrphanedPacker.py
#!/usr/bin/env python3
import datetime
import pytz
import boto3
def lambda_handler(event, context):
TerminateDelayDays = 3
StopDelayDays = 1
@UnixSage
UnixSage / send2s3.sh
Last active Mar 5, 2021
Simple shell script that uses curl to send a file to s3. Useful when you do not want to load the awscli for a simple job. May have to adjust mime types according to need.
View send2s3.sh
#!/bin/sh
if [ $# -ne 1 ] ; then
echo "Need File Name"
exit
fi
s3AccessKey="##ACCESS##"
s3SecretKey="##SECRET##"
s3Bucket="data.example.com"
@UnixSage
UnixSage / genpass.py
Last active Mar 3, 2021
SysAdmin Password Tool
View genpass.py
#!/usr/bin/env python3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@UnixSage
UnixSage / RotateAwsCreds.py
Created Mar 2, 2021
Handy of you have multiple aws accounts, utility that interrogates your aws config and generates aws-vault command lines and passwords to facilitate secret rotation.
View RotateAwsCreds.py
#!/usr/bin/env python3
import configparser
import re
import string
from random import choice
from os.path import expanduser
PasswordLength = 32
SpecialCount = 4
@UnixSage
UnixSage / SES-Send.sh
Created Sep 17, 2020
Send email via AWS SES from the command line
View SES-Send.sh
#!/bin/bash
DOMAIN="example.com"
MAILFROM="cmdline@${DOMAIN}"
MAILTO="someone@example.com"
SUBJECT="Amazon SES SMTP Test from ${HOSTNAME}"
USER="AWSKEY"
PASSWORD="AWSSMTPPASSWORD"
SMTPHOST="email-smtp.us-east-1.amazonaws.com:587"
@UnixSage
UnixSage / CalcHours.py
Last active Aug 1, 2020
Evenly split arbitrary groups of hours evenly across work days in a month
View CalcHours.py
#!/usr/bin/env python3
import calendar, datetime, holidays
import math
import os, json
# hours.json format
#
# {
# "Client1": 116,
@UnixSage
UnixSage / MonitorIP.py
Last active Jul 5, 2020
Simple script that will monitor a list of names and make sure the IPs match. Useful if you not using CNAMES for APEX domains. Output can be put on a web server and monitored for status.
View MonitorIP.py
#!/usr/bin/env python3
import socket
import datetime
domainlist = {
'home.mydomain.com': 'user.myisp.net',
'mydomain.com': 'account.myhosting.com'
}