Skip to content

Instantly share code, notes, and snippets.

@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
# printers.rb
Facter.add('printers') do
confine :kernel => %w{Linux FreeBSD OpenBSD SunOS Darwin}
confine do
Facter::Core::Execution.which('lpstat')
end
setcode do
output = Array.new
<?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
@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
@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]
@trodemaster
trodemaster / alternateSSHPort10.11.txt
Last active October 29, 2015 16:47
Configure OS X 10.11 to listen on an alternate ssh port.
1. Pick a port and hack up your /etc/services file
Change existing port entry from
mbus 47000/udp # Message Bus
mbus 47000/tcp # Message Bus
to..
ssh-47000 47000/udp # Alternate port SSH Remote Login Protocol
ssh-47000 47000/tcp # Alternate port SSH Remote Login Protocol
echo IzzyBoot for Fusion Drives
echo Version 1.0
echo
# Are we already encrypted?
if diskutil cs list | grep "Encrypted Extents" | grep -q "Yes"; then
echo It appears as though this drive is using FileVault2 encryption. This tool is too
echo simple to figure out what to do, but maybe you can use Disk Utility to repartition
echo the drive or remove the encryption first.
echo
@timsutton
timsutton / autopkg_jenkins_check.py
Last active December 27, 2015 00:19
Basic AutoPkg Jenkins check script in Python.
#!/usr/bin/python
#
# This is a rough Python script that demonstrates running AutoPkg with Jenkins
# as only a "check" action, using the ScriptTrigger plugin. It's assumed
# that AutoPkg is running directly out of a Git checkout from somewhere, but
# this is not necessary.
#
# Also note that the the '-d' option is given to hardcoded recipe
# search directories.
#
#!/usr/bin/python
import os
import subprocess
import urllib
import urllib2
import tempfile
import json
import shutil
from time import localtime