Skip to content

Instantly share code, notes, and snippets.

@thedoc31
thedoc31 / bundlecsr
Created April 4, 2016 23:24
Function for .bashrc which will bundle all new CSR files/folders under /etc/httpd/conf.d that have a date of now-1 into a tar file into a home folder. Tag filename with today's date.
bundlecsr() {
today=`date +%Y-%m-%d`
find /etc/httpd/conf.d/* -maxdepth 0 -mtime -1 | tar cvf /home/<username>/csrs_"$today".tar -T -
}
@thedoc31
thedoc31 / newcsr
Created April 4, 2016 23:26
Function for .bashrc which takes a commandline param of a name for an SSL cert, creates the right folder for it under /etc/httpd/conf.d and runs openssl with the right parameters to create the csr and key file.
newcsr() {
if [ $# -eq 0 ]
then
echo "Usage: newcsr www.my.sitename"; return
fi
mkdir /etc/httpd/conf.d/"$1".ssl
cd /etc/httpd/conf.d/"$1".ssl
openssl req -new -newkey rsa:2048 -nodes -out "$1".csr -keyout "$1".key
}
@thedoc31
thedoc31 / multiscp.sh
Created September 6, 2016 22:28
multiscp
#usage
#multiscp source_file.zip destination_ip_list.txt
#destination_ip_list.txt should only have IP addresses
multiscp(){
for dest in $(cat "$2"); do
scp "$1" ${dest}:/home/username
done
}
@thedoc31
thedoc31 / BatchSSHKeyCopy.cmd
Created February 3, 2017 23:13
Batch copy SSH key to multiple servers from an input text file
## serverlist should be FQDN or IP addresses, one server per line, no delimiters
## command will fail if serverlist.txt is not in UNIX format
while read name || [[ -n $name ]]; do sshpass -f ~/<yourpassword>.txt ssh-copy-id -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa.pub $name; done <serverlist.txt
@thedoc31
thedoc31 / OutputBindFriendlyServerList.cmd
Created February 3, 2017 23:16
Output BIND-friendly list of AWS servernames and EIP addresses based on name wildcard
## be sure your AWS default profile is set up, otherwise use --profile <profilename> to point it to the right account
aws ec2 describe-instances --filters "Name=tag:Name,Values=<wildcard-name-query-here>" --query "Reservations[*].Instances[*].[Tags[?Key=='Name'].Value[],PublicIpAddress]" | tr -d ' ["\r\n' | sed 's/\]\]\,/\r\n/g' | sed 's/\]\,/ 300 A /g' | tr -d ']' | sort
@thedoc31
thedoc31 / cq_trigger_blobgc.sh
Last active May 22, 2017 22:39 — forked from jayankandathil/cq_trigger_blobgc.sh
Shell script to trigger AEM6 BlobGC via curl and JMX
#!/bin/bash
# Bash script to trigger AEM Blob GC on localhost using curl via JMX
# Author : Jayan Kandathil (Adobe Managed Services)
# Version : 0.3
# Version Notes:
# 0.1 - Initial version
# 0.2 - autodetect environment and adjust port accordingly; handle and report errors appropriately
# 0.3 - update for AEM 6.2
@thedoc31
thedoc31 / fixawstags.sh
Last active August 28, 2017 19:50
Fix a batch of AWS Tags
aws --region us-west-2 ec2 describe-tags --filters "Name=tag:internalHostname,Values=*corp.adobe.com.corp.adobe.com" | sed 's/corp.adobe.com.corp.adobe.com/corp.adobe.com/g' > tagfix.json
resource=""
value=""
jq -rc '.Tags[]' tagfix.json | while IFS='' read tag; do
resource=$(echo $tag | jq -r .ResourceId)
value=$(echo $tag | jq -r .Value)
echo "Fixing $resource ($value)"
aws --region us-west-2 ec2 create-tags --resource $resource --tags Key=internalHostname,Value=$value
done
@thedoc31
thedoc31 / bulkknifeupload.sh
Created September 8, 2017 19:10
One-liner to find bulk modified chef environment files and upload them all to chef
git status | grep modified | grep json | sed 's/\(.*modified:\s*\)//' | while IFS='' read filename; do knife environment from file $(echo $filename); done
@thedoc31
thedoc31 / CollapseLanguages.sh
Created August 3, 2018 22:22
Find and collapse multiple RewriteRules with multiple languages into a single one-liner of all languages that use it
grep "<thecommonURL>" <thefile> | awk '{print $2}' | cut -c 2- | cut -f2-3 -d"/" | sort | tr '\n' '|'
"""fix_s3_owner_permissions"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
# import sys
import logging
import botocore
import boto3
DOCUMENTATION = '''
---