Skip to content

Instantly share code, notes, and snippets.

@thedoc31
thedoc31 / aem_querybuilder_oldpackages.txt
Created October 3, 2022 22:35
AEM QueryBuilder query to identify old packages stored below /etc/packages
# Query below will return packages not created, unwrapped, or unpacked by admin since the 'upperBound' date.
# Anything older than the upperBound date will be included. Anything newer is ignored.
# If Querybuilder returns blank results or stops processing because it traversed >100k nodes, you may want to consider
# adding the oak_index_ntFileLucene in one of my other gists. Otherwise, narrow the parameters such as using path=/etc/packages/my_packages.
path=/etc/packages
type=nt:file
p.limit=-1
p.hits=full
daterange.property=jcr:created
@thedoc31
thedoc31 / oak_index_ntFileLucene.json
Created October 3, 2022 22:28
AEM 6.x Package Index
# Below is an index definition you can add to AEM under /oak:index/ntFileLucene so you can efficiently search for old packages
# under the entire /etc/packages subtree if you're running up against the 100k node traversal limit. After adding this,
# you should have no issues searching/filtering on any of the properties listed. You can add other properties if you
# would rather search on those instead. Tested only on 6.5, but might be backward compatible to 6.3 or earlier.
#
# This index is NOT supported by Adobe Customer Care or Adobe AEM Engineering teams, it's just something I needed.
# Add at your own risk and as always, test thoroughly in lower environments before you put it in PROD.
{
"compatVersion": 2,
@thedoc31
thedoc31 / aws-instance-type-count
Last active March 18, 2022 16:56
Return count of instance types in use in current AWS region
aws ec2 describe-instances --filters Name=tag-key,Values=Name --query 'Reservations[*].Instances[*].{Instance:InstanceId,Instance:InstanceType}' --output text | sort | uniq -c
"""fix_s3_owner_permissions"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
# import sys
import logging
import botocore
import boto3
DOCUMENTATION = '''
---
@thedoc31
thedoc31 / grafana-dashboard-import.sh
Last active November 7, 2022 12:53
Bash script to batch Import dashboard JSON files into Grafana. Verified working on v6.3. This script is based on the Grafana dashboard export script originated on https://gist.github.com/crisidev/bd52bdcc7f029be2f295
#!/bin/bash
#
# add the "-x" option to the shebang line if you want a more verbose output
#
#
OPTSPEC=":hp:t:k:"
show_help() {
cat << EOF
Usage: $0 [-p PATH] [-t TARGET_HOST] [-k API_KEY]
@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' '|'
@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 / 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 / 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 / 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