So, I'm having an issue where my LaunchDaemon is not running the script that I have built that uses jamfHelper.
Here is my plist that I have:
<?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.MyCompany.UpdateTool</string>
<key>ProgramArguments</key>
<array>
<string>/var/StartupUpdateTool.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Now, I'm pretty sure it is running, I've checked the plist with plutil. So I'm not sure what is going on. When I switch it to a LaunchAgent, it works fine, but I want to try and pause the login process so that I can make some changes prior to the user logging in.
Here is the script.
#!/bin/bash
install_dir="/Library/Application Support/JAMF/UpdateTool/"
icon="/System/Library/CoreServices/Software Update.app/Contents/Resources/SoftwareUpdate.icns"
#Check for Network Connection
CheckForNetwork(){
local test
if [[ -z "${NETWORKUP:=}" ]]; then
test=$(ifconfig -a inet 2>/dev/null | sed -n -e '/127.0.0.1/d' -e '/0.0.0.0/d' -e '/inet/p' | wc -l)
if [[ "${test}" -gt 0 ]]; then
NETWORKUP="YES"
else
NETWORKUP="NO"
fi
fi
}
jamfHelper(){
sudo killall jamfHelper
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -title "Updating" -icon /System/Library/CoreServices/Software Update.app/Contents/Resources/SoftwareUpdate.icns -description "$1" -icon "$icon"
}
#unload login window
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.loginwindow.plist
#Unload Login Window allowing UpdateTool to start
#Sleep so loginlog can check up.
/bin/sleep 5
if [[ $NETWORKUP = "NO" ]]; then
jamfHelper "This Mac is being updated. Please plug the power in. Do not interrupt or power off:
Stage: Network
Status: No Connection"
/bin/sleep 3
else
jamfHelper "This Mac is being updated. Please plug the power in. Do not interrupt or power off:
Stage: Network
Status: Connected, checking for Casper Policies."
sudo jamf policy -verbose > /dev/null 2>&1
fi
if [ "$(ls -A "$install_dir")" ]; then
jamfHelper "This Mac is being updated. Do not interrupt or power off:
Stage: Updates
Status: Found Updates to install."
# Installing the packages found in
# the installers directory using
# an array
/bin/sleep 3
# Save current IFS state
OLDIFS=$IFS
# Change IFS to
# create newline
IFS=$'
'
# read all installer names into an array
install=($(/usr/bin/find $install_dir -maxdepth 2 ( -iname *.pkg -o -iname *.mpkg )))
# restore IFS to previous state
IFS=$OLDIFS
# Get length of the array
tLen=${#install[@]}
# Use for loop to read all filenames
# and install the corresponding installer
# packages
jamfHelper "This Mac is being updated. Do not interrupt or power off:
Stage: Updates
Status: Found ${tLen} packages to install."
for (( i=0; i<${tLen}; i++ ));
do
jamfHelper "This Mac is being updated. Do not interrupt or power off:
Stage: Updates
Status: Installing "${install[$i]}" on this Mac."
/usr/sbin/installer -dumplog -verbose -pkg "${install[$i]}" -target /
jamfHelper "This Mac is being updated. Do not interrupt or power off:
Stage: Updates
Status: Finished installing "${install[$i]}" on this Mac, now removing package."
/bin/rm -f "${install*}"
done
/bin/rm -rf "$install_dir"
jamfHelper "This Mac is being updated. Do not interrupt or power off:
Stage: Updates
Status: Finished all installations, now cleaning up."
/bin/sleep 5
/sbin/reboot
else
jamfHelper "This Mac is being updated. Do not interrupt or power off:
Stage: Updates
Status: No updates found to install, cleaning up and logging you in."
/bin/sleep 5
fi
killall jamfHelper
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.loginwindow.plist
exit 0