Skip to content

Instantly share code, notes, and snippets.

View carlashley's full-sized avatar

Carl carlashley

View GitHub Profile
@carlashley
carlashley / pythondeprecation.sh
Created November 11, 2021 02:42
Search logs for Python Deprecation Warnings - macOS Monterey
#!/bin/zsh
# Thanks to @golby on Slack:
sudo log show --info --debug --predicate 'process == "pythonprompt" AND eventMessage contains[cd] "Showing alert"'
@carlashley
carlashley / add_hostArchitectures.py
Last active November 27, 2020 08:52
Bulk add the arm64,x86_64 host architecture value to Packages .pkgproj files.
#!/usr/local/bin/python3
"""Bulk adds the 'arm64,x86_64' value as and advanced option for '.pkgproj' files.
Walks all sub directories specified at '[path]' for '.pkgproj' files, makes a backup
file in the same destination.
Does not add the value if a value already exists.
Usage: ./add_hostArchitectures.py [path]
Tested with Python 3.7.9.
"""
@carlashley
carlashley / ccimporter.py
Created November 27, 2020 04:11
Adobe CC Munki Import
#!/usr/local/bin/python3
"""This process unzipped Adobe CC packages and imports them into munki.
No copyright. Free for use, but no support provided.
This contains some fairly specific behaviour with regards to naming conventions:
- Converts filenames to lowercase, and replaces all space characters with '-'.
- Appends 'adobe-cc.' to the start of each package filename.
- Changes 'install' and 'uninstall' to 'installer' and 'uninstaller'.
- Optionally appends a suffix to the filenames and display titles in munki.
@carlashley
carlashley / createchoices.py
Created July 6, 2020 23:13
Create Choices XML for munki
#!/usr/local/bin/python3
"""Creates the required Choices XML for munki."""
from __future__ import print_function
import argparse
import os
import plistlib
import subprocess
import sys
@carlashley
carlashley / recovery_boot.txt
Created February 6, 2020 00:00
macOS Recovery Boot Mode Commands
# Local
sudo /usr/sbin/nvram recovery-boot-mode=unused # Boot to local recovery partition.
# Internet
sudo /usr/sbin/nvram internet-recovery-mode=RecoveryModeNetwork # Internet Recovery (same as SHIFT+OPT+CMD+R)
sudo /usr/sbin/nvram internet-recovery-mode=RecoveryModeDisk # Local Recovery Partition (Same as CMD+R)
sudo /usr/sbin/nvram internet-recovery-mode=DiagsModeDisk # Local Hardware Diagnostics (Same as D)
sudo /usr/sbin/nvram internet-recovery-mode=DiagsModeNetwork # Internet Hardware Diagnostics (Same as OPT+D)
# Sourced from
<?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>PayloadContent</key>
<dict>
<key>com.apple.touristd</key>
@carlashley
carlashley / codesign.example
Last active March 25, 2022 20:41
Code Signing Scripts on macOS
#Find valid code signing certificates with:
#/usr/bin/security find-identity -p codesigning -v
#Eg:
#[carl@pegasus]:outset # security find-identity -p codesigning -v
# 1) A898234JHSDFH38WERKHJSDFLJ2UY4092367HJK9H4J18 "Mac Developer: foo@example.org (ABC01FFFGH)"
# 1 valid identities found
#Code Sign file with:
#/usr/bin/codesign -s "Mac Developer: foo@example.org (ABC01FFFGH)" -i <bundleID> <file>
@carlashley
carlashley / current_user.py
Last active August 25, 2021 04:56
Returns a named tuple containing information about current logged in user.
#!/usr/bin/env python3
"""Current user logged into macOS, shamelessly stealing macmule's get current
logged in user from https://macmule.com/2014/11/19/how-to-get-the-currently-logged-in-user-in-a-more-apple-approved-way/"""
import pwd
import sys
from collections import namedtuple
try:
from SystemConfiguration import SCDynamicStoreCopyConsoleUser
@carlashley
carlashley / import_ova.sh
Last active October 6, 2017 03:17
Imports a VirtualBox OVA for currently logged in user.
#!/bin/sh
# This will import a VirtualBox OVA file for the currently logged in user; by default, when `VBoxManage import` is run in
# root environment, it will import the VM into a folder in the root user home directory.
# Handy for enabling self-service installs of a VM.
# The script is _very_ basic and doesn't have any form of version management/removal/upgrade capability, but this
# should be relatively easily expandable with the right `VBoxManage` commands.
#
# This example is for use in a package that doesn't actually install the OVA on disk, but imports it direct from the .pkg
# file. Essentially 'payload free', but not ;)
@carlashley
carlashley / touristd.mobileconfig
Created September 28, 2017 03:44
touristd notification prompts in macOS High Sierra
<?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>PayloadContent</key>
<dict>
<key>com.apple.touristd</key>