Skip to content

Instantly share code, notes, and snippets.

@mstathers
mstathers / split_certs.sh
Created July 11, 2019 20:11
Splits priv key, cert and chain out of a file and imports them into AWS Certificate Manager.
#!/bin/bash
pwd=$(pwd)
for file in *crt.pem; do
domain=$(echo $file | sed -e 's/.crt.pem//')
echo $domain
split -p "-----BEGIN CERTIFICATE-----" ${file} ${domain}-
# https://stackoverflow.com/questions/46572634/mysql-how-to-query-results-with-match-of-middle-text-digits
# Using test data:
mysql> select * from test;
+------------------------------------------------+
| data |
+------------------------------------------------+
| some00e |
| 01100001 |
#!/usr/bin/python
# https://stackoverflow.com/questions/46572634/mysql-how-to-query-results-with-match-of-middle-text-digits
import sys
import re
target = '0'
inString = sys.argv[1]
#!/bin/bash
# Will search for domains and add their A records to the firewall.
# Requires dig and iptables.
#
# /etc/cron.d/wordblock sample:
#
# */5 * * * * root /path/to/wordblock.sh
#
@mstathers
mstathers / backup.sh
Last active February 2, 2017 16:50
Will archive and compress given directories. Will these rotate weekly and daily. Will sync to s3 (requires awscli)
#!/bin/bash
set -e
backup_dirs=(
"/opt/"
"/root/"
"/etc/letsencrypt/"
"/etc/nginx/"
"/etc/cron.d/letsencrypt"
#!/usr/bin/perl
$|=1;
$count = 0;
$pid = $$;
while (<>) {
chomp $_;
if ($_ =~ /(.*\.jpg)/i) {
$url = $1;
system("/usr/bin/wget", "-q", "-O","/var/squid/images/$pid-$count.jpg", "$url");
system("/usr/bin/mogrify", "-flip","/var/squid/images/$pid-$count.jpg");
#!/bin/bash
# array to keep the names of our processes in
progs=(pureftp proftp)
for i in ${progs[@]}; do
# We want to see if it is running, but we don't care what it's PID is
pgrep $i > /dev/null
# was our pgrep successful?