Skip to content

Instantly share code, notes, and snippets.

View arubdesu's full-sized avatar
📛

Allister Banks arubdesu

📛
View GitHub Profile
@derak
derak / Jenkins AutoPkg build command
Last active June 20, 2016 20:52
AutoPkg build that pipes output to a log file. Build fails if nothing is added to munki.
#!/bin/sh
/usr/local/bin/autopkg run -v ${JOB_NAME}.munki MakeCatalogs.munki 2>&1 | tee /Users/Shared/Jenkins/tmp/${JOB_NAME}.log
RESULT=`grep rebuilt /Users/Shared/Jenkins/tmp/${JOB_NAME}.log`
if [ -n "$RESULT" ]; then
echo "${JOB_NAME} added to Munki repository. Build successful."
exit 0
else
echo "Nothing added to munki. Failing the build even though all is well."
exit 1
<?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>_metadata</key>
<dict>
<key>created_by</key>
<string>tsutton</string>
<key>creation_date</key>
<date>2014-10-20T14:55:20Z</date>
@bruienne
bruienne / sign_configprofile.sh
Created October 23, 2014 21:11
Sign config profile from CLI
openssl smime -sign -nodetach -in "My Awesome.mobileconfig" -signer MyAwesomeCert.pem -inkey MyAwesome.key -outform DER -out "My Awesome Signed.mobileconfig" -certfile MyAwesomeCert.pem
@jessepeterson
jessepeterson / reponotify.py
Last active August 5, 2019 16:40
reposado update notification: reports changed Apple products between repo_sync runs
#!/usr/bin/python
'''
reposado update notification: reports changed Apple products between repo_sync runs
Checks the current list of updates versus the previous list of updates and
reports on the changes. Run this script after your repo_sync run to see the
changes between syncs. You can then hand this report off in email if you wish.
For example:
@gregneagle
gregneagle / gist:01c99322cf985e771827
Created January 20, 2015 18:16
Using CFPreferences in Python to set a complex preference
import plistlib
import CoreFoundation
from Foundation import NSDate, NSMutableArray, NSMutableDictionary
# read the current ManagedPlugInPolicies
policy = CoreFoundation.CFPreferencesCopyAppValue("ManagedPlugInPolicies", "com.apple.Safari")
if policy:
# policy is an immutable dict, so we have to make a mutable copy
my_policy = NSMutableDictionary.alloc().initWithDictionary_copyItems_(policy, True)
@sheagcraig
sheagcraig / AdwareCheckExtensionAttribute.py
Last active November 27, 2021 23:51
Check for Adware per Apple Kbase article
#!/usr/bin/python
"""Identify or remove files known to be involved in Adware/Malware
infection.
Most of the code applies to building a list of malware files. Thus,
both extension attribute and removal handling are included.
Cleans files as a Casper script policy; thus, it expects four total
arguments, the first three of which it doesn't use, followed by
--remove
@pudquick
pudquick / pyCacher.py
Last active September 18, 2015 16:09
Playing with parsing Server caching service logs
import tempfile, os.path, shutil, glob, os, subprocess, re
debug = True
# It should take the logs from tmp and clone them somewhere
# It can then bunzip and combine them
def log(s):
global debug
if debug:
print s
@homebysix
homebysix / shard.sh
Last active November 7, 2025 20:32
shard.sh
#!/bin/bash
###
#
# Name: shard.sh
# Description: This Jamf Pro extension attribute takes a Mac serial
# number as input and uses that serial number to output a
# number from 0 to 9. This can be useful in scoping Jamf
# policies to a specific percentage of the fleet.
# Author: Elliot Jordan <[email protected]>
@pudquick
pudquick / defaut_ip.py
Created June 2, 2015 17:17
This snippet gets you the default routing interface for a machine for general traffic
def default_interface():
# 203.0.113.1 is reserved in TEST-NET-3 per RFC5737
# Should never be local, essentially equal to "internet"
# This should get the 'default' interface
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# Uses UDP for instant 'connect' and port 9 for discard
# protocol: http://en.wikipedia.org/wiki/Discard_Protocol
s.connect(('203.0.113.1', 9))
client = s.getsockname()[0]
#!/usr/bin/python
# As written, this requires the following:
# - OS X 10.6+ (may not work in 10.10, haven't tested)
# - python 2.6 or 2.7 (for collections.namedtuple usage, should be fine as default python in 10.6 is 2.6)
# - pyObjC (as such, recommended to be used with native OS X python install)
# Only tested and confirmed to work against 10.9.5
# Run with root