Local Script to check is JAMF was removed and reinstall

RaulSantos
Contributor

After JNUC 2013 and waiting for facebook to open source there code. I came up with this so far. create a LaunchD i no matter what user logs in it runs a script to check if /usr/sbin/jamf is on the computer if its not there it will try to ping the jss if it can ping the jss and the jamf binary is not there it will reinstall the quickadd pkg.

#!/bin/bash

JAMF=/usr/sbin/jamf
pkg=QUICKADD_PKG
JSS=JSS_SERVER

if [ -f $JAMF ];
then exit 0
else
if [ "ping -c 1 $JSS" ]

installer -pkg $pkg -target /
else exit 0

fi

exit 0

2 REPLIES 2

evarona
New Contributor II

Having not been able to attend JNUC (still pissed about that too!), I don't know the context of your script but noticed a closing fi was missing. I've done that and religiously indent to avoid that trap. I'd also change the JAMF variable to see if it already in the path and specify the path to the QA, FYIW. I hope you're not expecting it to be jamf download folder, in case that got deleted as well.

#!/bin/bash
JAMF=`which jamf`
pkg="/path/to/QUICKADD_PKG"
JSS="JSS_SERVER"

if [[ $JAMF ]] then
    exit 0 # jamf binary found
else
    if [ "`ping -c 1 $JSS`" ]
        installer -pkg $pkg -target /
    else
        echo "JSS unreachable"
        exit 1
    fi
fi
exit 0

user-yXXbTiAqAO
New Contributor

It can be much better