Skip to content

Instantly share code, notes, and snippets.

@apizz
apizz / appleloops_LogicPro_Mandatory_installcheck.bash
Last active July 15, 2020 01:45
installcheck_script for appleloops Logic Pro nopkg item for mandatory loops
#!/bin/bash
RECEIPT="/Library/Receipts/.appleLoopsLPMandatoryDone"
# If RECEIPT not present, run nopkg postinstall script
if [ ! -f "$RECEIPT" ]; then
exitcode=0
else
exitcode=1
fi
@apizz
apizz / appleloops_GarageBand_Mandatory_installcheck.bash
Last active July 15, 2020 01:45
installcheck_script for appleloops GarageBand nopkg item for mandatory loops
#!/bin/bash
RECEIPT="/Library/Receipts/.appleLoopsGBMandatoryDone"
# If RECEIPT not present, run nopkg postinstall script
if [ ! -f "$RECEIPT" ]; then
exitcode=0
else
exitcode=1
fi
@apizz
apizz / manual-rename-comp.bash
Last active July 19, 2021 09:05
Script to manually set a Mac's hostname
#!/bin/bash
currentCompName=$(/bin/hostname)
getCompName() {
newCompName=$(/usr/bin/osascript <<AppleScript
display dialog "Current computer name: ${currentCompName}
Please enter the new computer name below.
Example: YOUR_EXAMPLE_HOSTNAME_HERE" with title "Set New Computer Name" default answer ""
@apizz
apizz / verify-rename-comp.bash
Last active July 14, 2020 18:44
Script to be run after rename-comp.py to verify the configured hostname before continuing to provision a Mac.
#!/bin/bash
# Jamf script to be run after rename-comp.py to verify the configured hostname before continuing to provision
# a Mac.
#
# Usage:
#
# 1) Add this script to your Jamf instance
# 2) Configure the CSV variable below to match what you have listed in your rename-comp.py script
# 3) Add this script to your policy so that it runs AFTER rename-comp.py
@apizz
apizz / munki_preinstall_script_compareVersions.bash
Created July 11, 2020 19:23
Script to be used as a munki preinstall_script which will only succeed and subsequently install software if the Mac's macOS version matches one in the SUPPORTED_VERS list
#!/bin/bash
# Method inspired by:
# https://stackoverflow.com/questions/12768265/bash-compare-a-string-vs-a-list-of-strings
# Usage:
#
# While munki provides minimum_os_version and maximum_os_version to define a supported
# OS version range, some software define individual macOS versions as officially
# supported. In these cases, defining a supported range is helpful, but ultimately
@apizz
apizz / Suppress_System_Preference_Alert_Icon.mobileconfig
Created December 4, 2019 02:42
Example profile to suppress the red alert icon on the System Preferences app icon when software updates are available (10.14.x & later)
<?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>AttentionPrefBundleIDs</key>
<dict/>
<key>PayloadDisplayName</key>
@apizz
apizz / MathType7_License_Uninstall.sh
Last active November 30, 2019 20:35
Command line uninstall of MathType 7 license
#!/bin/bash
# MathType 7 license uninstall
APP_DIR="/Applications/MathType"
APP="${APP_DIR}/MathType.app"
EXE_PATH="${APP_DIR}/System/MathTypeLib"
PLIST="${APP}/Contents/Info.plist"
# Dummy receipt
RECEIPT="/Library/Receipts/.MathType7"
@apizz
apizz / MathType7_License_Install.sh
Created November 30, 2019 17:58
Command line install of MathType 7 license
#!/bin/bash
# Per https://docs.wiris.com/en/mathtype/mathtype_desktop/network_administrators_manual?s%5B%5D=silent&s%5B%5D=installation#macos
# Email
EMAIL="[email protected]"
# Path to MathTypeLib
EXE_PATH="/Applications/MathType/System/MathTypeLib"
# MathType 7 product key
KEY="XXXXX-YYYYY-ZZZZZ-AAAAA-BBBBB"
@apizz
apizz / preinstall_script.sh
Last active June 5, 2021 00:04
Munki item preinstall script to create a ppd for an AirPrint printer to be used as part of a nopkg item. Meant to be used along with something like https://github.com/nmcspadden/PrinterGenerator
#!/bin/bash
# Use the built-in ipp2ppd tool to create a PPD file for AirPrint
PRINTER_IP="ENTER_PRINTER_IP"
PPD="/etc/cups/ppd/PRINTER_NAME.ppd"
EXE="/System/Library/Printers/Libraries/ipp2ppd"
AIR_PPD="/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/AirPrint.ppd"
# Create the PPD file
@apizz
apizz / ForceReboot.sh
Created October 17, 2019 01:59
For triggering a restart if more than 1 loginwindow process is detected that is not the current logged in user or root after a user logs out
#!/bin/bash
# Determine loginwindow processes running and reboot the machine if
# more than 1 is detected.
USER=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk -F': ' '/[[:space:]]+Name[[:space:]]:/ { if ( $2 != "loginwindow" ) { print $2 }}')
# Searches for loginwindow processes and calculates the number running
LOGIN_PROCESSES=$(/usr/bin/pgrep loginwindow)
COUNTLOGINS=$(/bin/echo "$LOGIN_PROCESSES" | /usr/bin/wc -l | /usr/bin/sed 's/ //g')
LOG="/Library/Logs/ForceReboot.log"