Skip to content

Instantly share code, notes, and snippets.

@gregneagle
gregneagle / gist:fc66882e6fae64d82c8d
Created December 10, 2014 18:12
Demo of determining if a Google account has 2FA active
#!/usr/bin/python
# Demo of determinining if a Google account has 2FA active
# Needs a Google account ID (email address) and a password
# If the password is the "main" password (not an app-specific password)
# and "Two-factor authentication required" is returned; then 2FA is active
import urllib
import urllib2
#!/bin/sh
# Master login hook script
#
# runs each script found in the login hooks directory
LOGINHOOKSDIR="/etc/hooks/login"
if [ -d ${LOGINHOOKSDIR} ]; then
for script in ${LOGINHOOKSDIR}/* ; do
# sudo managedsoftwareupdate -vvvv --applesus
Managed Software Update Tool
Copyright 2010-2014 The Munki Project
http://code.google.com/p/munki
Starting...
Performing preflight tasks...
preflight stdout: Preflight report submmitted for Greg-Neagle--tic.
NOTE: managedsoftwareupdate is configured to process Apple Software Updates only.
Checking Apple Software Update catalog...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>catalogs</key>
<array>
</array>
<key>conditional_items</key>
<array>
<dict>
@gregneagle
gregneagle / First run
Last active August 29, 2015 14:05
Autopkg .install recipe demo
% ./autopkg run Firefox.install -v
Processing Firefox.install...
MozillaURLProvider
MozillaURLProvider: Found URL http://ftp.mozilla.org/pub/mozilla.org//firefox/releases/latest/mac/en-US/Firefox%2031.0.dmg
URLDownloader
URLDownloader: Storing new Last-Modified header: Thu, 17 Jul 2014 03:38:41 GMT
URLDownloader: Storing new ETag header: "4b25e62-3c17d83-4fe5b607b1240"
URLDownloader: Downloaded /Users/gneagle/Library/AutoPkg/Cache/com.github.autopkg.install.Firefox_EN/downloads/Firefox.dmg
EndOfCheckPhase
AppDmgVersioner
@gregneagle
gregneagle / gist:60ce73c7e267d993f1c1
Created August 13, 2014 17:23
Using the SystemConfiguration framework via PyObjC to get "ComputerName"
import SystemConfiguration
prefs = SystemConfiguration.SCPreferencesCreate(None, "SystemConfiguration", None)
print SystemConfiguration.SCPreferencesGetValue(prefs, "System")["System"]["ComputerName"]
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = "AdobeDreamweaverCS5.5.png"
>>> import os
>>> os.path.splitext(a)[1]
'.png'
>>> os.path.splitext(a)[0]
'AdobeDreamweaverCS5.5'
#!/usr/bin/python
"""
Programmatically altering plists with Python, shooting to add support to ansible
"""
import optparse
import FoundationPlist
# from munkilib import FoundationPlist
<?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>Description</key>
<string>Downloads and imports Munki 2 tools. Gets the latest build from https://munkibuilds.org/munkitools2-latest.pkg</string>
<key>Identifier</key>
<string>com.foo.autopkg.munki.munkitools2</string>
<key>Input</key>
<dict>
<?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>CalDAVAccountDescription</key>
<string>My Organization</string>
<key>CalDAVHostName</key>