Show off you extension attributes

RaulSantos
Contributor

I while back I put a post about showing off you Self Service. link This was great in the sense of giving the community ideas on how to use self service. After reading Shea Craig's article How We Are Removing Adware Am wondering how are you extending JAMF with extension attributes.

Come on all time show off you hard work.

8 REPLIES 8

rtrouton
Release Candidate Programs Tester

jrserapio
Contributor

Is there somewhere that states that an extension attribute can only output 1 if statement?

I have tested 1 EA with 3 (for now) if statements, but it only outputs the first one.

Trying to consolidate instead of having 30+ EAs for security compliance. for example:
EA name = Security

#!/bin/sh

a=1
if [ $a != 1 ]
then 
echo "<result>step 1 wrong</result>"
else
     :
fi

b=2
if [ $b != 2 ]
then 
echo "<result>step 2 wrong</result>"
else
     :
fi

c=3
if [ $c != 3 ]
then 
echo "<result>step 3 wrong</result>"
else
     :
fi

for a machine A where a=0, b=0, c=0, i would like the output to be:

Security: step 1 wrong step 2 wrong step 3 wrong

or Security: step 1 wrong step 2 wrong step 3 wrong

for machine B where a=1, b=2, c=3, i would like the output to be:

Security:

Thanks for looking. I will post my EAs once I clean them for sensitive data.

chriscollins
Valued Contributor

@jserapio No, since all you care about is what is between the results tags, you can make that anything you want to be. You just need to build the string of text that you want to be there (you have to get it all in one return tag since the JSS will only read in the first result tag returned). Normally in something like python I would build an array and then iterate through it to do that, but just to use your own simple example here, this is how I would modify it to do what you want:

#!/bin/sh

a=1
if [ $a != 1 ]
then 
    a_result="wrong"
else
    a_result="right"
fi

b=2
if [ $b != 2 ]
then 
    b_result="wrong"
else
     b_result="right"
fi

c=3
if [ $c != 3 ]
then 
    c_result="wrong"
else
     c_result="right"
fi

echo "<result>Step 1: $a_result, Step 2: $b_result, Step 3: $c_result</result>"

chriscollins
Valued Contributor

I've got a ton in my work's git repository that I need to sanitize as well, but here are some I recently started putting up: https://github.com/christophercollins/

jrserapio
Contributor

Thanks @chriscollins , I will give this a shot.

cwaldrip
Valued Contributor

Here's one for finding the version of BlackMagic drivers. Their v10 drivers updated their prefpanes and the version info in them is incorrect. This checks if the v9 drivers are there, and if not looks elsewhere for the version info.

#!/bin/bash

if [ -e /Library/PreferencePanes/DesktopVideoPrefsPanel.prefPane ]; then
    version=`defaults read /Library/PreferencePanes/DesktopVideoPrefsPanel.prefPane/Contents/Info.plist CFBundleVersion`
    if [[ $version =~ "^[0-9]+$" ]]; then
        bar=N/A
    else
        bar=$version
    fi
elif [ -e /Applications/Blackmagic Desktop Video/Blackmagic Multibridge Utility.app ]; then
    version=`defaults read /Applications/Blackmagic Desktop Video/Blackmagic Multibridge Utility.app/Contents/Info.plist CFBundleVersion`
    if [[ $version =~ "^[0-9]+$" ]]; then
        bar=N/A
    else
        bar=$version
    fi
else
        bar=N/A
fi

echo "<result>$bar</result>"

cwaldrip
Valued Contributor

And check the Matrox driver version.

#!/bin/bash
if [ -e /Library/PreferencePanes/com.matrox.vpg.MXO2.prefPane ]; then
     version=`defaults read /Library/PreferencePanes/com.matrox.vpg.MXO2.prefPane/Contents/Info.plist CFBundleShortVersionString`
     bar=$version
else
     bar=N/A
fi
echo "<result>$bar</result>"