Pushing Python3 failing

igal_tovievich
New Contributor II

Hey guys,

We're working on an automatic policy push of Python3 to people in the company. This can happen even once, but needs to happen to all the people.

This is the current script:

!/bin/bash

jamf policy -event PythonTrigger

-u $3 [ -f ~/.bash_profile ] && sed -i '' -e 's/(^./Python.framework/Versions/.$)/#1/' ~/.bash_profile && echo "Success updating .bash_profile" || echo "Failed updating .bash_profile"

-u $3 [ -f ~/.zprofile ] && sed -i '' -e 's/(^./Python.framework/Versions/.$)/#1/' ~/.zprofile && echo "Success updating .bash_profile"

-u $3 [ -f ~/.bashrc ] && sed -i '' -e 's/(^./Python.framework/Versions/.$)/#1/' ~/.bashrc && echo "Success updating .bash_profile"

Now, the script is running on a policy calling for the trigger. Another policy, the one with the package, has the PythonTrigger.
The policy that extracts the Python package runs successfully, and Python is installed in Applications.
However, after that part, the rest of the policy fails. Python should be at version 3.8.2 per the package, but when running Python3 at the terminal, it doesn't appear to be updated.

Would appreciate any input on the script/process!

Igal Tovievich
IT Manager
3 REPLIES 3

mschroder
Valued Contributor

Your script does not display properly, but I doubt that "-u $3 [ -f ~/.bash_profile ]" does what you expect it to do. I assume "$3" is the third parameter sent from the MDM, so the username. But which username? Are you making this available in the Self-Service, or do you push it out? What do expect the '~' resolves to in your context? Does it resolve at all?

mschroder
Valued Contributor

Something else just crossed my mind: does "jamf policy -event PythonTrigger" really wait that the policy finishes, or does it just trigger it? Scripts that require a package to be installed are a pain with JAMF.

I think I would

  • run a policy that installs the package and updates the inventory
  • have a smartgroup that includes all devices that have the new version
  • scope the policy that changes the .dot files to that smartgroup (run once)

sdagley
Esteemed Contributor II

@mschroder The jamf policy -event PythonTrigger won't return until the triggered policy completes