Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
import os
import subprocess
import urllib
import urllib2
import tempfile
import json
import shutil
from time import localtime
@grahamgilbert
grahamgilbert / boot_rom_version.py
Created March 5, 2015 20:49
boot_rom_version.py
#!/usr/bin/python
# Written in 10 minutes and tested on 10.10.2 only. Use with caution.
import subprocess
import plistlib
import os
from Foundation import CFPreferencesCopyAppValue
def boot_rom_version():
{
AppleSoftwareUpdatesOnly = 0;
ClientIdentifier = "";
LastCheckDate = "2014-03-18 20:50:21 +0000";
LastCheckResult = 1;
LogFile = "/Library/Managed Installs/Logs/ManagedSoftwareUpdate.log";
LoggingLevel = 1;
ManagedInstallDir = "/Library/Managed Installs";
PackageVerificationMode = hash;
SoftwareRepoURL = "https://munki.grahamgilbert.com/repo";
@grahamgilbert
grahamgilbert / com.grahamgilbert.crypt.launcher.plist
Created December 12, 2013 17:19
LaunchDaemon, LaunchAgent and script to run Crypt as root at login without using a loginhook. The user can click on the desktop and quit the app, but it does get around any networking issues that might happen when running before login is finished.
<?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>Label</key>
<string>com.grahamgilbert.crypt.launcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/crypt/Crypt.app/Contents/MacOS/Crypt</string>
</array>
#!/usr/bin/env bash
#
# This bootstraps an OS X Puppet Client
#
# Your Puppet server here
PUPPETSERVER='puppet.grahamgilbert.dev'
TESTURL='https://raw.github.com'
PUPPET_VER=`puppet --version`
@grahamgilbert
grahamgilbert / Makefile
Created September 12, 2013 15:52
Luggage Makefile that makes a Mac reboot
include /usr/local/share/luggage/luggage.make
TITLE=Enable_Auto_Time_Zone
PACKAGE_NAME=Enable_Auto_Time_Zone
REVERSE_DOMAIN=com.pebbleit
PAYLOAD=\
pack-script-postflight
PM_RESTART=RequiredRestart
@grahamgilbert
grahamgilbert / com.pebbleit.puppet.plist
Last active December 19, 2015 22:48
Our Puppet Launch Daemon
<?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>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/sbin:/usr/sbin:/bin:/usr/bin</string>
<key>RUBYLIB</key>
<string>/usr/lib/ruby/site_ruby/1.8/</string>
@grahamgilbert
grahamgilbert / puppet_conf.py
Created August 29, 2012 16:15
Script to write the puppet.conf for a Mac client using the serial as the certname
#!/usr/bin/env python
import subprocess
import re
from os import close
##put your puppet server here:
puppetserver = "puppet.example.com"
##get the system serial number
@grahamgilbert
grahamgilbert / init.pp
Created August 18, 2012 20:03
Location based printer setup
case $operatingsystem{
Darwin:{
##London is on the 10.30.2.0 and 10.30.3.0 Subnets
if ($network_en0 == '10.30.2.0') or ($network_en1 == '10.30.2.0') or ($network_en0 == '10.30.3.0') or ($network_en1 == '10.30.3.0'){
printer { "Sharp_ARM316":
ensure => present,
uri => "lpd://sharparm316.ldn.example.com",
description => "Sharp ARM316",
shared => false,
ppd => "/Library/Printers/PPDs/Contents/Resources/SHARP AR-M316.PPD.gz", # PPD file will be autorequired