Skip to main content
Question

Scripting help needed - launchdaemon


Show first post

bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 5, 2022

@Captainamerica  that sounds like an ownership/permissions issue. The script works from Jamf Pro because it runs all scripts as root. I'm not sure if that's the case for packaged post-install scripts.


Forum|alt.badge.img+8

If I deploy the package through Jamf to a machine, the launchdaemon is installed and loaded and everything fine. But when same package is in pre-stage, it does not load automatically


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 5, 2022

All I'm asking is that you try using the enrollment trigger. That's the best way to begin troubleshooting. You have to try different things to find the issue.


Forum|alt.badge.img+8

So you mean the 

$jamfBinary policy -event launchWizard

bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 5, 2022

 


Forum|alt.badge.img+8

arh ok - I understand. But this enrollment trigger in jamf is not very stable - sometimes it works other times not is that I experience. But can give it a try


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 5, 2022

Let me know how it goes, and I'll keep helping you troubleshoot.


Forum|alt.badge.img+8

If I just add the launchdaemon script and enrollment complete trigger it works, as you asked for. I checked the file rights on the plist file to compare if there are somehow set different when it is going through pre-stage, but they are exactly the same



bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 6, 2022

What is your prestage workflow? 


Forum|alt.badge.img+8

 

 

 


Forum|alt.badge.img+8

@bwoods Can you try and show you pre-stage setup in jamf. 
Do you have more packages in pre-stage or just one package with both jamf connect and the launchdaemon script ?

Even Low level - can you show how the package looks like if you show a composer view of the pkg ? Something is strange that the launchdaemon also for me cannot start 


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 13, 2022

@Captainamerica I install two packages at enrollment:

1. Automated Device Enrollment Starter

a. contains a preinstall script for rosetta for M1 hardware

b. DEPNotify

c. logos for DEPNotify.

 

2. A Location Services Package.

a. This contains a post install script that enables location services automatically. This could have been in the ADE starter but I already had it packaged in Jamf Pro. 

 

I install Jamf Connect with the DEPNotify GUI due to MFA policies at my organization. For now, I have my Desktop team create the accounts manually. But I have tested with Jamf Connect as well and it still works.

 


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 13, 2022

 


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 13, 2022

 


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 13, 2022

Script to install Rosetta

#!/bin/bash # Installs Rosetta as needed on Apple Silicon Macs. exitcode=0 # Determine OS version # Save current IFS state OLDIFS=$IFS IFS='.' read osvers_major osvers_minor osvers_dot_version <<< "$(/usr/bin/sw_vers -productVersion)" # restore IFS to previous state IFS=$OLDIFS # Check to see if the Mac is reporting itself as running macOS 11 if [[ ${osvers_major} -ge 11 ]]; then # Check to see if the Mac needs Rosetta installed by testing the processor processor=$(/usr/sbin/sysctl -n machdep.cpu.brand_string | grep -o "Intel") if [[ -n "$processor" ]]; then echo "$processor processor installed. No need to install Rosetta." else # Check Rosetta LaunchDaemon. If no LaunchDaemon is found, # perform a non-interactive install of Rosetta. if [[ ! -f "/Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist" ]]; then /usr/sbin/softwareupdate --install-rosetta --agree-to-license if [[ $? -eq 0 ]]; then echo "Rosetta has been successfully installed." else echo "Rosetta installation failed!" exitcode=1 fi else echo "Rosetta is already installed. Nothing to do." fi fi else echo "Mac is running macOS $osvers_major.$osvers_minor.$osvers_dot_version." echo "No need to install Rosetta on this version of macOS." fi exit $exitcode

bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 13, 2022

Script to enable location services automatically.

## configure ntp server /bin/cat > /etc/ntp.conf << 'NEW_NTP_CONF' server time.apple.com NEW_NTP_CONF ## configure automatic timezone /usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1 uuid=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57) /usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.$uuid LocationServicesEnabled -int 1 ## Set date and time automatically /usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool YES /usr/bin/defaults write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeOnlyEnabled -bool YES /usr/bin/defaults write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeZoneEnabled -bool YES /usr/sbin/systemsetup -setusingnetworktime on /usr/sbin/systemsetup -gettimezone /usr/sbin/systemsetup -getnetworktimeserver ### Restart location services daemon (locationd) /usr/bin/killall locationd exit 0; ## Success exit 1; ## Failure

Forum|alt.badge.img+8

Overall the issue seems to be the launchdaemon. It doesn´t start for some reason. I can read that launchdaemons can be tricky and must be very accurate or else the system will not load them. 


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 13, 2022

 


Forum|alt.badge.img+8

so in pre-stage you do not put in the creation of launchdaemon ? that is where I have it - I first launch depnotify when user desktop is loaded


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • January 13, 2022

My launchdaemon creation script and DEPNotify scripts are always in the cloud so that I can edit them without creating a new package. 


Forum|alt.badge.img+8

Think we found the issue now. The jamf binary does note exist in pre-stage when the launchdaemon executes - so somehow just have to build in that the launchdaemon first launch when the jamf binary exist in the path


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings