Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
DECODE_BASE64(){
# This function takes the encoded output from ldapsearch and decodes it
# It then needs to be "hex-dumped" in order to get it into regular text
# So that we can work with it
OBJECT_ID="$1"
BASE64_DECODED=$(echo $OBJECT_ID | base64 -D)
G=($(echo ${BASE64_DECODED} | hexdump -e '16/1 " %02X"'))
OBJECTGUID="${G[3]}${G[2]}${G[1]}${G[0]}-${G[5]}${G[4]}-${G[7]}${G[6]}-${G[8]}${G[9]}-${G[10]}${G[11]}${G[12]}${G[13]}${G[14]}${G[15]}"
@calum-github
calum-github / ldapsearch.sh
Last active November 29, 2016 23:51
Ldap search query
#!/bin/bash
## Start by loading up our ldap query variables
SVC_ACCOUNT_NAME="Username"
SVC_ACCOUNT_PASS="Password"
DOMAIN="my.domain"
LDAP_SERVER="dc.my.domain:389"
SEARCH_BASE="OU=Users,DC=My,DC=Domain"
ldapsearch -LLL -H ldap://$LDAP_SERVER -E pr=1000/noprompt -o ldif-wrap=no -x -D ${SVC_ACCOUNT_NAME}@$DOMAIN -w ${SVC_ACCOUNT_PASS} -b "${SEARCH_BASE}" \
case $FIRST_CHAR in
A)
NUMBER=2 ;;
B)
NUMBER=3 ;;
C)
NUMBER=4 ;;
D)
NUMBER=5 ;;
E)
@calum-github
calum-github / enable_email_alerts.py
Last active December 21, 2016 15:30
Add email address to macOS alerts DB to enable email alerts
#!/usr/bin/python
import sqlite3
import sys
import time
import os
import csv
# Variables and paths
DB_PATH = '/Library/Server/Alerts/alertData.db'
@calum-github
calum-github / gist:18f3b1e14e31e08d238c2f398cb3a9af
Last active July 19, 2016 00:04
Munki Conditionals excerpt - iLife / iWork
# Match our Model Identifier and determine eligibility based on what bundled software the machine came with
case $getModel in
iMac17,1|iMac16,2|iMac16,1|iMac15,1|iMac14,4|iMac14,3|iMac14,2|iMac14,1) # iMac's with iWork and iLife
iwork=TRUE
ilife=TRUE
write_conditionals
notify_success;;
iMac13,1|iMac13,2|iMac12,1|iMac12,2) # iMacs with just iLife
iwork=FALSE
ilife=TRUE
{
"cache" => [
]
"dnsPublicAddressRanges" => [
]
"version" => 6
"serversRecentlySeen" => [
]
}
sh-3.2# plutil -p /var/folders/yd/y87k7kk14494j_9c0y814r8c0000gp/C/com.apple.AssetCacheLocatorService/diskCache.plist
@calum-github
calum-github / format_hd.sh
Last active August 10, 2020 21:20
Disk formatter
#!/bin/bash
########################################################################
# Author: Calum Hunter #
# Date: 21/12/2016 #
# Version: 0.7 #
# Purpose: Fusion Drive Detection and general HD formatting before #
# imaging tasks. #
# #
########################################################################
#!/bin/bash
# Version 0.5
# Install check for the AD Bind Package.
# This script checks to see if 1. We are bound to AD and if our binding is working.
# If we are not bound, or our binding is broken, lets go ahead and try to rebind
#
# If we exit this script with 1, then we should _not_ attempt a rebind.
# If we exit this script with 0, then we _SHOULD_ attempt a rebind.
@calum-github
calum-github / Disable_FUS_Menu_Item.mobileconfig
Created March 7, 2016 05:24
Disable Fast User Switching Menu Item
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadContent</key>
<dict>
<key>com.apple.mcxMenuExtras</key>
@calum-github
calum-github / enable_fus.mobileconfig
Last active September 2, 2016 02:49
Enable Fast User Switching
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadContent</key>
<dict>
<key>.GlobalPreferences</key>