Extension Attribute to find a plist / lightspeed filter installed

Mscheid
New Contributor III

We have just started using LightSpeed Filtering and I am looking for a way (extension Attribute) to determine it is installed on a computer. It adds two small clients on the computer but they are hard to find. It also adds two plist files to Library/Preferences. Does anyone have an extension attribute that I can use to find if these specific plist files are installed?

2 ACCEPTED SOLUTIONS

rockpapergoat
Contributor III

ls's -l option gives you the long output, not grep.

you could do a simple test in bash, sort of like this:

#!/usr/bin/env bash

file="/etc/ntp.conf"

if [[ -e $file ]]; then
    echo "yes"
elif [[ ! -e $file ]]; then
    echo "no"
fi

in ruby (and other languages) you can make it even simpler. here's an example:

#!/usr/bin/env ruby

result = File.exist?("/etc/ntp.conf")  ? "yes" : "no"
puts "<result>#{result}</result>"

likewise, if you're dealing with plugins, you probably want to track versions. here's an example in ruby: https://github.com/rockpapergoat/scripts/blob/master/misc/get_app_version.rb

View solution in original post

Mscheid
New Contributor III

Excellent!! I had to add the <result> </result> so the JSS would report but other than that it works Great!!

#!/usr/bin/env bash

file="/Library/Preferences/com.lightspeedsystems.useragent.plist"

if [[ -e $file ]]; then echo <result>yes</result>
elif [[ ! -e $file ]]; then echo <result>no</result>
fi

View solution in original post

5 REPLIES 5

adthree
New Contributor III

It's nothing super fancy but you can create a script for an extension attribute that lists a dir and then greps for a certain file name/type.

#!/bin/sh
result=`ls -l /dir/where/files/live | grep filename.filename`
echo "<result>$result</result>"

We use this @ my work to locate a .conf file that lives in /private/etc/ and a smart group that lists who has and who doesn't have the file, tied to this is an ongoing policy that installs the .conf file on machines that don't have it. I've not had much time to look into greps manual but when it prints the result it adds all of the file details

-rwxrwxrwx 1 root wheel 120 Jun 6 2011 sysctl.conf

I'm sure grep has a switch you can turn on to not print this info but due to laziness I've not looked into it.

rockpapergoat
Contributor III

ls's -l option gives you the long output, not grep.

you could do a simple test in bash, sort of like this:

#!/usr/bin/env bash

file="/etc/ntp.conf"

if [[ -e $file ]]; then
    echo "yes"
elif [[ ! -e $file ]]; then
    echo "no"
fi

in ruby (and other languages) you can make it even simpler. here's an example:

#!/usr/bin/env ruby

result = File.exist?("/etc/ntp.conf")  ? "yes" : "no"
puts "<result>#{result}</result>"

likewise, if you're dealing with plugins, you probably want to track versions. here's an example in ruby: https://github.com/rockpapergoat/scripts/blob/master/misc/get_app_version.rb

Mscheid
New Contributor III

Excellent!! I had to add the <result> </result> so the JSS would report but other than that it works Great!!

#!/usr/bin/env bash

file="/Library/Preferences/com.lightspeedsystems.useragent.plist"

if [[ -e $file ]]; then echo <result>yes</result>
elif [[ ! -e $file ]]; then echo <result>no</result>
fi

rmanly
Contributor III

There are several reasons why you shouldn't parse the output of ls. Not the least of which is calling an external command and spawning subshells.

Here are the really bad reasons why you should not do it.

http://mywiki.wooledge.org/ParsingLs

Mscheid
New Contributor III

rmanly, Not sure what you are trying to say about the output of ls...