Skip to content

Instantly share code, notes, and snippets.

@apizz
apizz / TeamViewerHost_Install.sh
Created May 2, 2019 14:36
Downloads and installs the desired TeamViewer Host major version
#!/bin/bash
# Downloads the latest TeamViewer Host package, effectively going to
# get.teamviewer.com/YOURCUSTOMHOSTURL in a browser.
########################################################
LOGFILE="/Library/Logs/TeamViewerInstall.log"
DOWNLOADDIR="/Users/Shared"
# Ex. 12, 13, or 14
MAJORVERSION="13"
@apizz
apizz / docker_snipeit_dbbackup.sh
Last active September 25, 2024 23:43
Backup a specified Snipe-IT Docker container and cleanup any old backups
#!/bin/bash
#
# Script for running automated backups for Snipe-IT Docker containers and removing old backups
#
# Mean to be used as part of a crontab
#
# Limits its search for backups to clean up to those in the 'BACKUP_DIR' folder, so
# you can create folders in this location to keep any manual backups for historical purposes
#
@apizz
apizz / TeamViewerHost-Extended-Attribute-postinstall.sh
Last active February 11, 2020 17:57
Writes the supplied TeamViewer Host configuration ID to the TeamViewer Host app. For use with munki.
#!/bin/sh
ATTR="com.TeamViewer.ConfigurationId"
CONFIG_ID="<your_custom_config_id>"
TVHOST="/Applications/TeamViewerHost.app"
STATUS=$(/usr/bin/xattr -l "$TVHOST")
# If no extended attribute present, write it
if [ "$STATUS" = "" ]; then
/bin/echo "Writing TeamViewer Host configuration ID ..."
@apizz
apizz / com.google.Chrome.plist
Created September 19, 2019 00:28
Our administrative default settings for the Chrome web browser
<?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>BookmarkBarEnabled</key>
<true/>
<key>HomepageIsNewTabPage</key>
<false/>
<key>HomepageLocation</key>
<string>https://www.mastersny.org</string>
@apizz
apizz / com.google.Chrome.plist
Created September 19, 2019 00:54
Example of preferences we enforce via profile in our MDM
<?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>ExtensionSettings</key>
<dict>
<!-- uBlock Origin -->
<key>cjpalhdlnbpafiamejdnhcphjbkeiagm</key>
<dict>
<key>installation_mode</key>
@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"
@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 / 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 / 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 / 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>