Depnotify for normal package install ?

Captainamerica
Contributor

If I want to upgrade Office with a new package (complete new install) is it possible to use depnotify ? - or can this only be used when a mac is starting up the first time and part of dep ?

Do any has some good tutorial on using Depnotify. I have seen the official githib, but I need some examples code, to be able to understand what is needed. Don´t know if any has some links ?

Also, if other tools can be used when installing larger packages so there is a visable box with information for the user, and not only the "slide in and slide out" notification

13 REPLIES 13

Nix4Life
Valued Contributor

Hoppy Shaw of Alaska Airlines did a talk at Macadmins 2019 using DEPNotify non-DEP workflows, may give you some Ideas. I "borrowed" quite a bit from his talk

here

Captainamerica
Contributor

Yes just saw some. Could still use a really beginner level example in non dep.

install package install - show splash screen - and when done remove splash screen.

stevewood
Honored Contributor II

@Captainamerica

I use DEPNotify to upgrade one of our agency's video production suite to CC 2019. It works great for providing feedback:

#!/bin/bash

###############################################################################
# Name: upgrade-Adobe2019.sh
# Date: 2019 May 31
# Author: Steve Wood (steve.wood@omnicomgroup.com)
# Purpose: used to install the Adobe 2019 apps and all plug-ins
###############################################################################

###### ****** for testing set to TRUE
TESTING_MODE=false


### Setup some logging
logFile="/var/log/us-das-ohg-link9Adobe2019-$(date +%Y%m%d-%H%M).log"
logPath='/var/log/'
## Setup logging
if [[ ! -d "${logPath}" ]]; then

    mkdir -p "${logPath}"

fi

function ScriptLog() { # Re-direct logging to the log file ...

    exec 3>&1 4>&2        # Save standard output and standard error
    exec 1>>"${logFile}"    # Redirect standard output to logFile
    exec 2>>"${logFile}"    # Redirect standard error to logFile

    NOW=`date +%Y-%m-%d %H:%M:%S`
    /bin/echo "${NOW}" " ${1}" >> ${logFile}

}
ScriptLog "*** Starting our script ***"

## setup Caffeinate to stay awake
/bin/echo "Loads of Coffee Now!!"
/bin/date
caffeinate -d -i -m -u &
caffeinatepid=$!

### some variables
jb='/usr/local/bin/jamf'
dnlog='/var//tmp/depnotify.log'
defaults='/usr/bin/defaults'

### setup the list of apps to install
### "borrowed" from Jamf's DEP Setup script: https://github.com/jamf/DEPNotify-Starter
#########################################################################################
# Policy Variable to Modify
#########################################################################################
# The policy array must be formatted "Progress Bar text,customTrigger". These will be
# run in order as they appear below.
POLICY_ARRAY=(
    "Installing Adobe After Effects,aftereffects2019"
    "Installing Adobe Animate,animate2019"
    "Installing Adobe Audition,audition2019"
    "Installing Adobe Bridge,bridge2019"
    "Installing Adobe Character Animator,characteranimator2019"
    "Installing Adobe Illustrator,illustrator2019"
    "Installing Adobe InDesign,indesign2019"
    "Installing Adobe Media Encoder,mediaencoder2019"
    "Installing Adobe Photoshop,photoshop2019"
    "Installing Adobe Premiere Pro,premiere2019"
    "Installing Adobe Creative Cloud,ccda-elevated"
    "Installing Duik & RubberHose Plug-ins,duik-rubberhose"
    "Installing Animation Composer,animationcomposer"
    "Installing Plexus,us-das-lin-plexus"
    "Installing Red Giant,us-das-lin-redgiant"
    "Installing Color Vibrance,colorvibrance"
    "Installing Reflect,reflect"
    "Installing Sure Target,suretarget"
    "Installing Twitch,us-das-lin-twitch"
    "Installing Orb,orb"
    "Installing Saber,saber"
    "Installing Optical Flares,us-das-lin-opticalflares"
    "Installing Element3D,us-das-lin-element3d"
    "Installing ProShaders 2,us-das-lin-proshaders"
    "Installing Flip4Mac,flip4mac"
    "Installing ScreenFlow,screenflow"
    "Installing Neat Video,neatvideo"
    "Installing Reel Smart Motion Blur,reelsmartmotionblur"
    "Installing AE Scripts,aescripts"
)

### setup DEP notify for progress screen
## get logo
ScriptLog "*** Setting up logo ***"
if [[ ! -f "/your/it/folder/your_logo.png" ]]; then

    ScriptLog "*** Downloading logo ***"
    curl -sKO https://URL-To-An-Image-File -o /tmp/your-image.png
    echo "Command: Image: /tmp/your-image.png" >> ${dnlog}

else

    ScriptLog "*** Loading logo from local ***"

    echo "Command: Image: /your/it/folder/your_logo.png" >> ${dnlog}

fi

## setup command file
echo "Command: Determinate: 30" >> ${dnlog}
echo "Command: MainTitle: Adobe CC 2019 Installation" >> ${dnlog}
echo "Command: WindowTitle: Adobe CC 2019 Installation" >> ${dnlog}
echo "Command: MainText: We are installing the Adobe CC 2019 applications on your machine. Please do not unplug from power or shut down your computer." >> ${dnlog}
echo "Status: Starting installations" >> ${dnlog}

## install DEP Notify so we can use it
ScriptLog "*** Installing DEP Notify ***"
${jb} policy -event depnotify

ScriptLog "Creating DEPNotify LaunchAgent"
/bin/echo "<?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>Label</key>
    <string>com.corp.launchdepnotify</string>
    <key>ProgramArguments</key>
    <array>
        <string>/tmp/DEPNotify.app/Contents/MacOS/DEPNotify</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>" > /Library/LaunchAgents/com.corp.launchdepnotify.plist
##Set the permission on the file just made.
/usr/sbin/chown root:wheel /Library/LaunchAgents/com.corp.launchdepnotify.plist
/bin/chmod 644 /Library/LaunchAgents/com.corp.launchdepnotify.plist

## Now launch DEP Notify
/bin/launchctl load /Library/LaunchAgents/com.corp.launchdepnotify.plist

ScriptLog "*** Starting policy installations"
## install stuff
for POLICY in "${POLICY_ARRAY[@]}"; do
    echo "Status: $(echo "$POLICY" | cut -d ',' -f1)" >> "$dnlog"
    if [ "$TESTING_MODE" = true ]; then
      sleep 5
    elif [ "$TESTING_MODE" = false ]; then
      "$jb" policy -event "$(echo "$POLICY" | cut -d ',' -f2)" --forceNoRecon
    fi
done

echo "Command: Notification: Done Installing Adobe CC 2019" >> "$dnlog"

/bin/launchctl unload /Library/LaunchAgents/com.corp.launchdepnotify.plist

/bin/echo "Evacuating coffee"
/bin/date
kill "$caffeinatepid"

exit 0

That runs in a window state that can be moved out of the way to do other things. If you want it totally in your face, you could run in full screen mode by changing this:

    <array>
        <string>/tmp/DEPNotify.app/Contents/MacOS/DEPNotify</string>
    </array>

To this:

<array>
    <string>/tmp/DEPNotify.app/Contents/MacOS/DEPNotify</string>
    <string>-fullScreen</string>
</array>

jwojda
Valued Contributor II

@stevewood how would this be run? I'm trying to setup for use in self service, but my initial depnotify package was setup based off of @arekdreyer 's work and I've been struggling to adapt for a new use case. His process had a post install script for the DepNotify.pkg, which worked perfectly for DEP, but not so much for Self Service.

stevewood
Honored Contributor II

@jwojda

Well, you'd need a policy that just installs DEPNotify with a trigger of whatever custom trigger you want. In my case it's depnotify. You can see that in this snippet of code:

## install DEP Notify so we can use it
ScriptLog "*** Installing DEP Notify ***"
${jb} policy -event depnotify

My DEPNotify package drops the app into this location: /tmp/DEPNotify.app/Contents/MacOS/DEPNotify So if you drop anywhere else you'll need to edit that in the above script.

It's really just a matter of editing the language, what verbiage you want, and then adjusting the list of policies to run. When the script runs it creates a LaunchAgent that it then loads and that kicks everything off.

And to be clear, my DEPNotify package is only DEPNotify, no post install scripts or anything.
Hopefully that all makes sense.

jwojda
Valued Contributor II

@stevewood yeah, it does. I modified and created a new depnotify installer/policy, script calls the install policy, creates the LaunchA, but I don't think it ever runs it.

I can copy and paste the command into terminal from the script and THEN it opens depnotify, but it has no config to run.

stevewood
Honored Contributor II

@jwojda

Do you have these bits in your script, right after you write out the LA:

##Set the permission on the file just made.
/usr/sbin/chown root:wheel /Library/LaunchAgents/com.corp.launchdepnotify.plist
/bin/chmod 644 /Library/LaunchAgents/com.corp.launchdepnotify.plist

## Now launch DEP Notify
/bin/launchctl load /Library/LaunchAgents/com.corp.launchdepnotify.plist

Obviously naming the LA whatever you want instead of com.corp.launchdepnotify.plist.

jwojda
Valued Contributor II

@stevewood yeah, it looks like it does all that...

+ date '%Y-%m-%d %H:%M:%S'
NOW='2020-08-07 15:55:02'
/bin/echo '2020-08-07 15:55:02' ' Starting our script '
2020-08-07 15:55:02 Starting our script
/bin/echo 'Loads of Coffee Now!!'
Loads of Coffee Now!!
/bin/date
Fri Aug 7 15:55:02 CDT 2020
caffeinatepid=6490
jb=/usr/local/bin/jamf
dnlog=/private/var/log/depnotify.log
defaults=/usr/bin/defaults
POLICY_ARRAY=(<multiple apps here> "Preparing for the next login,")
ScriptLog ' Setting up logo '
caffeinate -d -i -m -u
exec
exec
exec
+ date '%Y-%m-%d %H:%M:%S'
NOW='2020-08-07 15:55:02'
/bin/echo '2020-08-07 15:55:02' ' Setting up logo '
2020-08-07 15:55:02 Setting up logo
[[ ! -f /Library/Scripts/Logo.png ]]
ScriptLog ' Loading logo from local '
exec
exec
exec
date '%Y-%m-%d %H:%M:%S'
NOW='2020-08-07 15:55:02'
/bin/echo '2020-08-07 15:55:02' ' Loading logo from local '
2020-08-07 15:55:02 Loading logo from local
echo 'Command: Image: /Library/Scripts/Logo.png'
echo 'Command: Determinate: 30'
echo 'Command: MainTitle: Provisioning Mac'
echo 'Command: WindowTitle: Initial Setup of Device'
echo 'Command: MainText: We are provisioning your machine and loading applications on your machine. Please do not unplug from power or shut down your computer.'
echo 'Status: Starting installations'
ScriptLog ' Installing DEP Notify '
exec
exec
exec
+ date '%Y-%m-%d %H:%M:%S'
NOW='2020-08-07 15:55:03'
/bin/echo '2020-08-07 15:55:03' ' Installing DEP Notify '
2020-08-07 15:55:03 Installing DEP Notify
/usr/local/bin/jamf policy -event depnotifyInstall
Checking for policies triggered by "depnotifyInstall" for user "<admin>"...
Executing Policy -TEST- 00 - DEPNotify Install
Downloading DEPNotify.pkg...
Downloading https://jamf/download/<randomstrings>/DEPNotify.pkg?...
Verifying package integrity...
Installing DEPNotify.pkg...
Successfully installed DEPNotify.pkg.
Submitting log to https://jamf/
ScriptLog 'Creating DEPNotify LaunchAgent'
exec
exec
exec
date '%Y-%m-%d %H:%M:%S'
NOW='2020-08-07 15:55:13'
/bin/echo '2020-08-07 15:55:13' ' Creating DEPNotify LaunchAgent'
2020-08-07 15:55:13 Creating DEPNotify LaunchAgent
/bin/echo '<?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>Label</key> <string>com.corp.launchdepnotify</string> <key>ProgramArguments</key> <array> <string>/Applications/Utilities/DEPNotify.app/Contents/MacOS/DEPNotify</string> </array> <key>RunAtLoad</key> <true/>
</dict>
</plist>'
/usr/sbin/chown root:wheel /Library/LaunchAgents/com.corp.launchdepnotify.plist
/bin/chmod 644 /Library/LaunchAgents/com.corp.launchdepnotify.plist
/bin/launchctl load /Library/LaunchAgents/com.corp.launchdepnotify.plist
ScriptLog ' Starting policy installations'
exec
exec
exec
+ date '%Y-%m-%d %H:%M:%S'
NOW='2020-08-07 15:55:13'
/bin/echo '2020-08-07 15:55:13' '
Starting policy installations'
2020-08-07 15:55:13 * Starting policy installations
for POLICY in '"${POLICY_ARRAY[@]}"'
echo 'Prompting for computer name'
cut -d , -f1
echo 'Status: Prompting for computer name'
'[' True = true ']'
'[' True = false ']'
for POLICY in '"${POLICY_ARRAY[@]}"'
echo 'Installing Office,msOffice'
cut -d , -f1
echo 'Status: Installing Office'
'[' True = true ']'
'[' True = false ']'

..MULTIPLE APPS LISTED..

  • for POLICY in '"${POLICY_ARRAY[@]}"' + echo 'Preparing for the next login,comamnd' + cut -d , -f1
  • echo 'Status: Preparing for the next login'
  • '[' True = true ']'
  • '[' True = false ']'
  • echo 'Command: Notification: Done Provisioning Device'
  • /bin/launchctl unload /Library/LaunchAgents/com.corp.launchdepnotify.plist /Library/LaunchAgents/com.corp.launchdepnotify.plist: Operation now in progress
  • /bin/echo 'Evacuating coffee' Evacuating coffee
  • /bin/date Fri Aug 7 15:55:13 CDT 2020
  • kill 6490
  • exit 0

stevewood
Honored Contributor II

@jwojda

Ok, I think what's happening is that you've moved the location you are writing the depnotify.log file to. The default location is /var/tmp/depnotify.log. If you're going to change that you need to pass the -path flag when calling DEPNotify. You can read about it on the GitLab page:

DEPNotify Readme.md

jwojda
Valued Contributor II

thank you @stevewood it got further after correcting that, but depnotify still wouldn't pop until I logged out and logged back in, but then it didn't do anything, just sat there and didn't process the script.
I'm going to start over on the script and not change anything and see how it goes.

jwojda
Valued Contributor II

@stevewood Looks like I have things running pretty smoothly now, except for 1 issue. it appears that if the Self Service policy is run more than once, it seems to launch DepNotify multiple times, both with the testing flag set true or false. It's not a BIG deal, but I've tried deleting the LaunchAgent and the depnotify.app but it always launches multiple instances of it. Is it possible to have it check if Depnotify.app is present in the folder and only install if it's not found? Not sure if that would address the issue or not.

During one of my testing sessions, when I noticed it first, I accidentally grabbed and dragged the window and found another behind it... eventually discovered there was 6 running instances. The only way I could get it to go back to one was by spinning up a fresh VM.

stevewood
Honored Contributor II

@jwojda

Wrapping the line where you install DEPNotify with a simple if/then check for its existence would be all you should need I would think. That is assuming you are not installing DEPNotify as a package on the same Self Service policy.

In my script above these lines:

## install DEP Notify so we can use it
ScriptLog "*** Installing DEP Notify ***"
${jb} policy -event depnotify

Would become:

## install DEP Notify so we can use it
ScriptLog "*** Installing DEP Notify ***"
if [[ ! -f "/tmp/DEPNotify.app/Contents/MacOS/DEPNotify" ]]; then
    ${jb} policy -event depnotify
fi

Or something like that.

jwojda
Valued Contributor II

@stevewood thank you! That worked for the no longer installing on top of itself, but it still double launches when run multiple times.

I believe there's some cleanup stuff that can be run to prevent that, I will dig into it.
f458346bf4cb417e85539519b400a736