This repository has been archived by the owner on Jun 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from homebysix/v2.0-rc1
Merge version 2.0 to master.
- Loading branch information
Showing
56 changed files
with
1,314 additions
and
550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?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>Identifier</key> | ||
<string>local.jss.Firefox-testing</string> | ||
<key>Input</key> | ||
<dict> | ||
<key>CATEGORY</key> | ||
<string>Web Browsers</string> | ||
<key>GROUP_NAME</key> | ||
<string>%NAME%-update-smart</string> | ||
<key>GROUP_TEMPLATE</key> | ||
<string>SmartGroupTemplate.xml</string> | ||
<key>LOCALE</key> | ||
<string>en_US</string> | ||
<key>NAME</key> | ||
<string>Firefox</string> | ||
<key>POLICY_CATEGORY</key> | ||
<string>Testing</string> | ||
<key>POLICY_TEMPLATE</key> | ||
<string>PolicyTemplate.xml</string> | ||
<key>RELEASE</key> | ||
<string>latest</string> | ||
<key>SELF_SERVICE_DESCRIPTION</key> | ||
<string>Web Browser.</string> | ||
<key>SELF_SERVICE_ICON</key> | ||
<string>Firefox.png</string> | ||
</dict> | ||
<key>ParentRecipe</key> | ||
<string>com.github.jss-recipes.jss.Firefox_EN</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?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>Identifier</key> | ||
<string>local.jss.Firefox-autoupdate</string> | ||
<key>Input</key> | ||
<dict> | ||
<key>GROUP_NAME</key> | ||
<string>%NAME%-autoupdate</string> | ||
<key>GROUP_TEMPLATE</key> | ||
<string>SmartGroupTemplate-autoupdate.xml</string> | ||
<key>POLICY_CATEGORY</key> | ||
<string>Auto Update</string> | ||
<key>POLICY_TEMPLATE</key> | ||
<string>PolicyTemplate-autoupdate.xml</string> | ||
</dict> | ||
<key>ParentRecipe</key> | ||
<string>com.github.jss-recipes.jss.Firefox_EN</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#!/bin/bash | ||
|
||
### | ||
# | ||
# Name: auto_update_magic.sh | ||
# Description: A script and LaunchDaemon pair designed to leverage | ||
# autopkg, AutoPkgr, JSSImporter, and Casper to keep apps on | ||
# Mac endpoints up to date automatically. Details at: | ||
# https://github.com/homebysix/auto-update-magic | ||
# Author: Elliot Jordan <[email protected]> | ||
# Created: 2013-03-24 | ||
# Last Modified: 2015-09-22 | ||
# Version: 2.0 | ||
# | ||
### | ||
|
||
|
||
################################## SETTINGS ################################### | ||
|
||
# Add a line here for each auto update custom trigger. This is almost always | ||
# the same as the recipe's name. Trigger and recipe names may contain spaces. | ||
TRIGGERS=( | ||
|
||
# "Adobe Flash Player" | ||
|
||
# "Firefox" | ||
|
||
# "Google Chrome" | ||
|
||
# "Oracle Java 7" | ||
|
||
# "Oracle Java 8" | ||
|
||
# "MSOffice2011" | ||
|
||
) | ||
|
||
# For each recipe above, add a corresponding line here for each "blocking | ||
# application" (apps/processes that must not be open if the app is to be | ||
# updated automatically). You can add multiple comma-separated applications per | ||
# line. Use `pgrep _____` to test whether the blocking behaves as expected. | ||
BLOCKING_APPS=( | ||
|
||
# "Safari, Firefox" # blocking apps for Flash | ||
|
||
# "Firefox" # blocking apps for Firefox | ||
|
||
# "Google Chrome" # blocking apps for Chrome | ||
|
||
# "Safari, Firefox" # blocking apps for Java 7 | ||
|
||
# "Safari, Firefox" # blocking apps for Java 8 | ||
|
||
# "MSN Messenger, Microsoft Lync, Microsoft Cert Manager, Microsoft Chart Converter, Microsoft Clip Gallery, Microsoft Entourage, Microsoft Outlook, Microsoft Error Reporting, Microsoft Excel, Microsoft Graph, Microsoft Help Viewer, Microsoft Language Register, Microsoft Communicator, Microsoft Messenger, Microsoft PowerPoint, Microsoft Query, Microsoft Word, My Day, Organization Chart, Expression Media, Remote Desktop Connection" # blocking apps for latest Office 2011 update | ||
|
||
) | ||
|
||
# Preference list that will be used to track last auto update timestamp. | ||
# Omit ".plist" extension. | ||
PLIST="/Library/Application Support/JAMF/com.jamfsoftware.jamfnation" | ||
|
||
# Set DEBUG_MODE to true if you wish to do a "dry run." This means the custom | ||
# triggers that cause the apps to actually update will be logged, but NOT | ||
# actually executed. Set to false prior to deployment. | ||
DEBUG_MODE=true | ||
|
||
|
||
############################################################################### | ||
######################### DO NOT EDIT BELOW THIS LINE ######################### | ||
############################################################################### | ||
|
||
|
||
######################## VALIDATION AND ERROR CHECKING ######################## | ||
|
||
APPNAME=$(basename "$0" | sed "s/\.sh$//") | ||
|
||
# Let's make sure we have the right numbers of settings above. | ||
if [[ ${#TRIGGERS[@]} != ${#BLOCKING_APPS[@]} ]]; then | ||
echo "[ERROR] Please carefully check the settings in the $APPNAME script. The number of parameters don't match." >&2 | ||
exit 1001 | ||
fi | ||
|
||
# Let's verify that DEBUG_MODE is set to true or false. | ||
if [[ $DEBUG_MODE != true && $DEBUG_MODE != false ]]; then | ||
echo "[ERROR] DEBUG_MODE should be set to either true or false." >&2 | ||
exit 1002 | ||
fi | ||
|
||
if [[ -x /usr/sbin/jamf ]]; then | ||
jamf=/usr/sbin/jamf | ||
elif [[ -x /usr/local/bin/jamf ]]; then | ||
jamf=/usr/local/bin/jamf | ||
else | ||
echo "[ERROR] The jamf binary could not be found." >&2 | ||
exit 1003 | ||
fi | ||
|
||
|
||
################################ MAIN PROCESS ################################# | ||
|
||
# Count how many recipes we need to process. | ||
RECIPE_COUNT=${#TRIGGERS[@]} | ||
|
||
# Save the default internal field separator. | ||
OLDIFS=$IFS | ||
|
||
# Begin iterating through recipes. | ||
for (( i = 0; i < RECIPE_COUNT; i++ )); do | ||
|
||
echo " " # for some visual separation between apps in the log | ||
|
||
# Iterate through each recipe's corresponding blocking apps. | ||
echo "Checking for apps that would block the ${TRIGGERS[$i]} update..." | ||
IFS="," | ||
UPDATE_BLOCKED=false | ||
|
||
for APP in ${BLOCKING_APPS[$i]}; do | ||
|
||
# Strip leading spaces from app name. Save lowercase version. | ||
APP_CLEAN="$(echo "$APP" | sed 's/^ *//')" | ||
APP_CLEAN_LOWER="$(echo "$APP_CLEAN" | tr "[:upper:]" "[:lower:]")" | ||
|
||
# Check whether the app is running. | ||
if pgrep "$APP_CLEAN" &> /dev/null || pgrep "$APP_CLEAN_LOWER" &> /dev/null; then | ||
echo " $APP_CLEAN is running. Skipping auto update." | ||
UPDATE_BLOCKED=true | ||
break | ||
else | ||
echo " $APP_CLEAN is not running." | ||
fi | ||
|
||
done | ||
|
||
# Only run the auto-update policy if no blocking apps are running. | ||
if [[ $UPDATE_BLOCKED == false ]]; then | ||
if [[ $DEBUG_MODE == false ]]; then | ||
echo "No apps are blocking the ${TRIGGERS[$i]} update. Calling policy trigger autoupdate-${TRIGGERS[$i]}." | ||
$jamf policy -event "autoupdate-${TRIGGERS[$i]}" | ||
else | ||
echo "[DEBUG] No apps are blocking the ${TRIGGERS[$i]} update. This is the point where we would run:" | ||
echo " $jamf policy -event \"autoupdate-${TRIGGERS[$i]}\"" | ||
fi | ||
fi | ||
|
||
done # End iterating through recipes. | ||
|
||
# Reset back to default internal field separator. | ||
IFS=$OLDIFS | ||
|
||
# Record the timestamp of the last auto update check. | ||
if [[ $DEBUG_MODE == false ]]; then | ||
/usr/bin/defaults write "$PLIST" LastAutoUpdate "$(date +%s)" | ||
fi | ||
|
||
exit 0 |
19 changes: 19 additions & 0 deletions
19
Exercise5c/com.jamfsoftware.jamfnation.auto_update_magic.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?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>Comment</key> | ||
<string>A script and LaunchDaemon pair designed to leverage autopkg, AutoPkgr, JSSImporter, and Casper to keep apps on Mac endpoints up to date automatically. Details at: https://github.com/homebysix/auto-update-magic </string> | ||
<key>Label</key> | ||
<string>com.jamfsoftware.jamfnation.auto_update_magic</string> | ||
<key>ProgramArguments</key> | ||
<array> | ||
<string>sh</string> | ||
<string>/Library/Scripts/auto_update_magic.sh</string> | ||
</array> | ||
<key>RunAtLoad</key> | ||
<true/> | ||
<key>StartInterval</key> | ||
<integer>3600</integer> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
|
||
### | ||
# | ||
# Name: create_pkg.sh | ||
# Description: This script automatically creates a pkg file that you can | ||
# use to deploy the Auto Update Magic script/LaunchDaemon | ||
# pair to your managed clients. | ||
# Author: Elliot Jordan <[email protected]> | ||
# Created: 2015-09-18 | ||
# Last Modified: 2015-09-23 | ||
# Version: 1.0.1 | ||
# | ||
### | ||
|
||
cd "$(dirname "$0")" | ||
|
||
if [[ ! -f "./auto_update_magic.sh" || | ||
! -f "./com.jamfsoftware.jamfnation.auto_update_magic.plist" || | ||
! -f "./pkg_scripts/postinstall" ]]; then | ||
echo "[ERROR] At least one required file is missing. Ensure that the following files exist in the Exercise5c folder:" | ||
echo " auto_update_magic.sh" | ||
echo " com.jamfsoftware.jamfnation.auto_update_magic.plist" | ||
echo " pkg_scripts/postinstall" | ||
exit 1 | ||
fi | ||
|
||
script_md5=$(md5 -q ./auto_update_magic.sh) | ||
if [[ "$script_md5" == "a1fd08b32853ca004212e98d7ea5a99e" ]]; then | ||
echo "[ERROR] It looks like you haven't customized the auto_update_magic.sh script yet. Please do that now, then run create_pkg.sh again." | ||
exit 2 | ||
fi | ||
|
||
read -p "[SANITY CHECK] Have you already added the TRIGGERS to auto_update_magic.sh? [y/n]: " -n 1 check_triggers | ||
echo | ||
if [[ "$check_triggers" != "y" && "$check_triggers" != "Y" ]]; then | ||
echo "You should go back and add the TRIGGERS to auto_update_magic.sh now, then run create_pkg.sh again." | ||
exit 3 | ||
fi | ||
|
||
read -p "[SANITY CHECK] Have you already added the BLOCKING_APPS to auto_update_magic.sh? [y/n]: " -n 1 check_blocking_apps | ||
echo | ||
if [[ "$check_blocking_apps" != "y" && "$check_blocking_apps" != "Y" ]]; then | ||
echo "You should go back and add the BLOCKING_APPS to auto_update_magic.sh now, then run create_pkg.sh again." | ||
exit 4 | ||
fi | ||
|
||
read -p "[SANITY CHECK] Have you already adjusted the StartInterval in the com.jamfsoftware.jamfnation.auto_update_magic LaunchDaemon to your liking? [y/n]: " -n 1 check_schedule | ||
echo | ||
if [[ "$check_schedule" != "y" && "$check_schedule" != "Y" ]]; then | ||
echo "You should go back and adjust the StartInterval now, then run create_pkg.sh again." | ||
exit 5 | ||
fi | ||
|
||
echo "Great! Sounds like you're good to go." | ||
|
||
TMP_PKGROOT="/private/tmp/auto_update_magic/pkgroot" | ||
echo "Building package root in /tmp folder..." | ||
mkdir -p "$TMP_PKGROOT/Library/LaunchDaemons" "$TMP_PKGROOT/Library/Scripts" | ||
|
||
echo "Copying the files to the package root..." | ||
cp "./com.jamfsoftware.jamfnation.auto_update_magic.plist" "$TMP_PKGROOT/Library/LaunchDaemons/" | ||
cp "./auto_update_magic.sh" "$TMP_PKGROOT/Library/Scripts/" | ||
|
||
echo "Setting mode and permissions..." | ||
chown -R root:wheel "$TMP_PKGROOT" | ||
chmod +x "$TMP_PKGROOT/Library/Scripts/auto_update_magic.sh" | ||
|
||
echo "Building the package..." | ||
pkgbuild --root "/tmp/auto_update_magic/pkgroot" \ | ||
--scripts "./pkg_scripts" \ | ||
--identifier "com.jamfsoftware.jamfnation.auto_update_magic" \ | ||
--version "2.0" \ | ||
--install-location "/" \ | ||
"./auto_update_magic-$(date "+%Y%m%d").pkg" | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
launchctl load -w /Library/LaunchDaemons/com.jamfsoftware.jamfnation.auto_update_magic.plist | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?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>Identifier</key> | ||
<string>local.jss.AdobeFlashPlayer-autoupdate</string> | ||
<key>Input</key> | ||
<dict> | ||
<key>NAME</key> | ||
<string>Adobe Flash Player</string> | ||
<key>GROUP_NAME</key> | ||
<string>%NAME%-autoupdate</string> | ||
<key>GROUP_TEMPLATE</key> | ||
<string>AdobeFlashPlayerSmartGroupTemplate-autoupdate.xml</string> | ||
<key>POLICY_CATEGORY</key> | ||
<string>Auto Update</string> | ||
<key>POLICY_TEMPLATE</key> | ||
<string>PolicyTemplate-autoupdate.xml</string> | ||
</dict> | ||
<key>ParentRecipe</key> | ||
<string>com.github.jss-recipes.jss.AdobeFlashPlayer</string> | ||
</dict> | ||
</plist> |
Oops, something went wrong.