Skip to content

Instantly share code, notes, and snippets.

@rtrouton
rtrouton / gist:c09f8ed541d330c4c7d4
Last active January 10, 2017 21:43
Automated setup script for OS X Server 5.0.x and later
#!/bin/bash
# This script is designed to automate the setup of OS X Server 5.0.3 and later
# by authorizing and using the 'server' tool within /Applications/Server.app to
# run the initial setup and configuration of OS X Server's services.
# Script will check for the existence of the 'server' setup tool. If the 'server' setup tool
# is not located where the script expects it to be, the script will exit.
if [[ ! -e "/Applications/Server.app/Contents/ServerRoot/usr/sbin/server" ]]; then
@rtrouton
rtrouton / gist:df24a3b1162605046a9e
Created September 24, 2015 01:07
ARD task template for running commands with Casper's jamf binary
#!/bin/bash
CheckBinary (){
# Identify location of jamf binary.
jamf_binary=`/usr/bin/which jamf`
if [[ "$jamf_binary" == "" ]] && [[ -e "/usr/sbin/jamf" ]] && [[ ! -e "/usr/local/bin/jamf" ]]; then
jamf_binary="/usr/sbin/jamf"
@rtrouton
rtrouton / gist:81985ffb4865085724c8
Created August 19, 2015 00:59
Figuring out if a home folder was created today or not.
#!/bin/bash
homefolder="$(mdls -raw -name kMDItemFSCreationDate $HOME | awk '{ print $1 }')"
if [[ "$homefolder" == $(date +"%Y-%m-%d") ]]; then
echo "Created today!"
fi
@rtrouton
rtrouton / com.apple.loginwindow.plist
Created August 14, 2015 16:45
Disable "Reopen windows..." on logout, restart or shutdown
<?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>TALLogoutSavesState</key>
<string>0</string>
</dict>
</plist>
@rtrouton
rtrouton / gist:55d107a569978a1b2113
Created August 10, 2015 13:19
Disabling First-run dialogs in Office 2016 for Mac
#!/bin/bash
# Disabling First-run dialogs in Office 2016 for Mac
# Link: http://macops.ca/disabling-first-run-dialogs-in-office-2016-for-mac/
if [[ -e "/Applications/Microsoft Excel.app" ]]; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.Excel kSubUIAppCompletedFirstRunSetup1507 -bool true
elif [[ -e "/Applications/Microsoft OneNote.app" ]]; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.onenote.mac kSubUIAppCompletedFirstRunSetup1507 -bool true
elif [[ -e "/Applications/Microsoft Outlook.app" ]]; then
@rtrouton
rtrouton / gist:49101bfe86a6833fb38a
Last active November 30, 2016 05:00
Reading Apple JDK version number
java -version 2>&1 | awk 'NR==1{ gsub(/"/,""); print $3 }'
defaults read $(/usr/libexec/java_home | sed 's/Home//g' | sed s'/.$//')/Info CFBundleIdentifier | grep -o "apple"
defaults read $(/usr/libexec/java_home | sed 's/Home//g' | sed s'/.$//')/Info CFBundleIdentifier | grep -o "oracle"
Answer: defaults read $(/usr/libexec/java_home | sed 's/Home//g' | sed s'/.$//')/Info CFBundleIdentifier | grep -o "apple\|oracle"
@rtrouton
rtrouton / javaJDKextAtty.txt
Last active August 29, 2015 14:26 — forked from dderusha/javaJDKextAtty.txt
Java JDK Extension Attribute
###Test Code###
### Intention is to figure out what JDK the user has installed.
### our current Ext atty reports the JRE, we need to know they have the JDK
## thanks to elliotjordon
## -00 is just a number to say that JDK is not installed. makes for better smartgroup searches
###############
if JDKver=$(ls "/Library/Java/JavaVirtualMachines" | awk -F "_|.jdk" '/.jdk/{print $2}' | tail -1)
then
echo "<result>$JDKver</result>"
# else
#!/usr/bin/python
import plistlib, os.path
# Based off of https://forums.developer.apple.com/message/6741
def jdk_info_plists():
# Find all the JDK Info.plist files
JDK_ROOT = "/Library/Java/JavaVirtualMachines"
if (os.path.exists(JDK_ROOT) and os.path.isdir(JDK_ROOT)):
# It's present, let's look for installs
@rtrouton
rtrouton / cipher.sh
Last active January 14, 2016 20:45 — forked from opragel/cipher.sh
#!/bin/bash
# Add the user and group used by Tomcat on your Linux
# server. For Casper 9.x running on Red Hat Enterprise
# Linux, the user and group are filled in below.
linux_tomcat_user="tomcat7"
linux_tomcat_group="tomcat7"
# Add the user and group used by Tomcat on your Linux