Skip to content

Instantly share code, notes, and snippets.

@bochoven
bochoven / users.py
Created June 3, 2017 05:37
macOS: Get all local users and calculate the size of the homedirectory
#!/usr/bin/python
# Get all local users and calculate the size of the homedirectory
import os, pwd, plistlib
system_accounts = ['root', 'daemon', 'nobody', 'Guest']
account_list = []
def get_size(start_path):
total_size = 0
#!/bin/sh
# Script that creates two installer packages with the same destination app
# but different CFBundleIdentifiers.
# These trigger in macOS installer the creation of a .localized version
mkdir -p /tmp/test/Applications/Test.app/Contents
/usr/libexec/plistbuddy -c "Add :CFBundleIdentifier string macadmins.test.1" /tmp/test/Applications/Test.app/Contents/Info.plist
pkgbuild --root /tmp/test /tmp/test.1.pkg
/usr/libexec/plistbuddy -c "Set :CFBundleIdentifier string macadmins.test.2" /tmp/test/Applications/Test.app/Contents/Info.plist
@bochoven
bochoven / stack_ibook_sync.py
Created April 11, 2019 14:21
Downloads iBooks from a public Stack repository.
#!/usr/bin/python
# encoding: utf-8
''' Downloads iBooks from Stack storage
Complexity is a result from the CSRF token that is needed for the download.
'''
import urllib, urllib2, json, re, cookielib, os, xattr
from Cocoa import NSWorkspace, NSImage
PAGE_URL = 'https://username.stackstorage.com/s/6hjYxxxxKnp6x'
@bochoven
bochoven / department_to_passphrase.sh
Created December 4, 2020 10:15
Set MunkiReport Machinegroup based on Jamf department
#!/bin/sh
# This ugly script sets the proper passphrase per department
# it retrieves the department via the JAMF API
API_URL=https://YOURJAMFSERVER:8443/JSSResource
API_USER=api_user
API_PASS=$4
# Get serial number
myserial=$(system_profiler SPHardwareDataType | awk '/Serial Number/{print $4}')