Skip to content

Instantly share code, notes, and snippets.

@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. #
# #
########################################################################
{
"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 / 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
@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'
case $FIRST_CHAR in
A)
NUMBER=2 ;;
B)
NUMBER=3 ;;
C)
NUMBER=4 ;;
D)
NUMBER=5 ;;
E)
@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}" \
#!/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 / convert.sh
Last active July 23, 2020 23:35
AD Plugin UID calculation from ObjectGUID
#!/bin/bash
#
# Author: Calum Hunter
# Date: 28/11/2016
# Version: 1.0
# Purpose: To generate a Mac UID from the objectGUID attribute
# (GeneratedUID) in AD.
# This uses the same method that the Apple
# AD Plugin uses
@calum-github
calum-github / ad.sh
Last active December 1, 2016 02:49
iterate over ad users to determine uid
#!/bin/bash
#
# Author: Calum Hunter
# Date: 28/11/2016
# Version: 1.0
# Purpose: To generate a Mac UID from the objectGUID attribute
# (GeneratedUID) in AD.
# This uses the same method that the Apple
# AD Plugin uses
@calum-github
calum-github / mount_shares.py
Created December 24, 2016 00:46
mount shares in python
#!/usr/bin/python
############################################################
# #
# Author: Calum Hunter #
# Date: 10-10-2016 #
# Version: 2.30 #
# Purpose: Mount shares using NetFS #
# Credit: Big shout outs to Frogor and Mosen for this #
# This is all pretty much their code #