Posted on 01-30-2009 09:49 AM
We now have a need to figure out how many machines have windows on them or not. I would like to run a report with Casper that will go through inventory and if a Mac doesn't have a NTFS partition on it with Windows I want it on one list, and if it does I want it on another list so we can tell what machines dual boot and which ones don't.
Any ideas?
Posted on 01-30-2009 10:07 AM
Dummy package. Loop through your /Volumes with:
haswindows=diskutil info $volume | grep -c NTFS
if [ $haswindows -ne 0 ] ; then
issue the custom trigger to install the dummy package. Scope your smart
group to the existence of the dummy package.
You may want to double check that "NTFS" is what you want to grep for. I
don't have any NTFS volumes to test this with.
----------
Miles A. Leacy IV
? Certified System Administrator 10.4
? Certified Technical Coordinator 10.5
? Certified Trainer
Certified Casper Administrator
----------
voice: 1-347-277-7321
miles.leacy at themacadmin.com
www.themacadmin.com
Posted on 01-30-2009 10:17 AM
Hi-
Looking through the man page for df, you may be able to use the -T flag to specify NTFS (or whatever that partition type shows up as in the OS).
So for example, you could get an output of everything that's hfs by doing
%df -T hfs
Or, everything that's not hfs by doing
%df -T nohfs
Wonder if the same could be held for NTFS (can't try as I don't have a windows partition on anything)
j
Posted on 01-30-2009 10:29 AM
will this dummy package log only machines that have windows then in the
policy logs? How exactly does this work?
Posted on 01-30-2009 10:35 AM
A dummy package is just an empty package. Name it something appropriate and
recognizable such as "windowsMachines.pkg".
Create a policy with a custom trigger to install this package.
Create a second policy that runs on all of your machines which runs the
script that I half-wrote in my last message. That script issues the custom
trigger for the policy to install the dummy package if it finds an NTFS
volume.
What you end up with is each machine that has an NTFS volume also has a
receipt for windowsMachines.pkg. You then create a smart group whose
criteria is machines with the windowsMachines.pkg receipt.
----------
Miles A. Leacy IV
? Certified System Administrator 10.4
? Certified Technical Coordinator 10.5
? Certified Trainer
Certified Casper Administrator
----------
voice: 1-347-277-7321
miles.leacy at themacadmin.com
www.themacadmin.com
Posted on 01-30-2009 10:44 AM
ah got it, so basically the install will only tirgger if the criteria of
having an ntfs partition is met and then of course the policy log will
have a recipt of every machine that it runs on. That is a damn creative
way to do that. I like it.
In response to Jared Nichols email, you sir are correct. I just test it
out. df -T ntfs does in fact show the volume that the windows partition
is on and nothing else. good call on that one
Posted on 02-13-2009 08:19 AM
Ok advanced casper users....OK, well I mean Miles...
I have written the following script I want to run to install a dummy pkg
to make a smart group on machines that have windows or not. So, here is
my script, but I am not quite piecing it all together. I think I am
missing a few small steps
#!/bin/bash
#determine if there is an NTFS volume on a mac, and run casper policy
accordingly.
fs=/bin/df -T ntfs
for a in /bin/df -T ntfs ; do
if [[ $a != $fs ]] && continue
/usr/sbin/jamf install <dummypkg_name.pkg>
else
echo "NTFS partition found”
fi
done
exit
So I should just create a blank package and call it, Winders XP or
whatever. Then put it in Casper Admin and sync the shares. Then set
the trigger to custom. Then I should make that script another policy
and have it execute say, every hour once a day or whatever. Then apply
it to all my user machines. The machines that have windows will be
ignored and the ones that do have it will get that dummy package
installed. Then I can create a smart group off the receipts....
This is my first time using a dummy package like this, so any pointers
would be greatly appreciated. I also just wrote that script 5 minutes
ago and only had 1 cup of coffee and am still learning how to properly
code loops in shell scripts, so if my syntax is off, well I could use
pointers there as well.
Thanks,
Posted on 02-13-2009 08:42 AM
Actually, I already see a flaw in my script, it is always going to work
because if the NTFS is not present they will always not equal each
other....
maybe if I did it by volume name? All the windows volumes have the same
name.
Posted on 02-13-2009 08:49 AM
Here's what I'd do and why...
#!/bin/bash
# Find ntfs partitions. If you have no ntfs partitions, `df -T ntfs` will
return nothing.
# If there are ntfs partitions, you'll get output that looks like:
# /dev/disk0s4 32358320 73712 32284608 1% /Volumes/DevDisk
hasntfspart=df -T ntfs | grep -c /
# $hasntfspart now = 0 if there are no ntfs partitions, and >0 if there are
any.
# Install a dummy package if an ntfs partition is found.
# I always install my dummy packages via policies, using custom triggers.
# Create your dummy package, and a custom-triggered policy to install it.
# In this example, I use flagForWindows as my custom trigger.
# The name of the package is unimportant for the purposes of this script.
if [ $hasntfspart -ne 0 ]
then jamf policy -trigger flagForWindows
else echo "no ntfs partition found"
fi
# The jamf binary contacts the JSS and runs any policies that have a trigger
of
# "flagForWindows" if the value of $hasntfspart is >0.
# That's it.
# If you want to be elegant about your coding, you can throw an `exit` in at
the end.
----------
Miles A. Leacy IV
? Certified System Administrator 10.4
? Certified Technical Coordinator 10.5
? Certified Trainer
Certified Casper Administrator
----------
voice: 1-347-277-7321
miles.leacy at themacadmin.com
www.themacadmin.com
Posted on 02-13-2009 08:49 AM
Sorry to spam the list
so if I did something more on the lines like this
#bin/bash
win=".Local Disk"
for i in /bin/ls -a /Volumes | grep .Local
do
if [[ $i != $win ]] && continue
/usr/sbin/jamf install dummy.pkg
else
echo "NTFS volume found'
fi
done
exit
Posted on 02-13-2009 09:05 AM
Awesome Miles, thanks, you rock
One more quick question. Since I don't ever trigger custom packages, I
just name the policy whatever, then use the trigger option with the
policy name behind it?
Thanks again for your help
Posted on 02-13-2009 09:18 AM
No problem.
The name of the policy isn't important; the trigger is. In the execution
options section of the policy's general tab, choose "other (Manually specify
the run at action in this field) -->" from the "triggered by" drop down
menu. In the text field next to that menu, type your custom trigger
("flagForWindows" in my example).
The command below will run your policy, and any other policies for which you
choose to specify "flagForWindows" as a custom trigger.
jamf policy -trigger flagForWindows
This command also works with the standard triggers, i.e.:
jamf policy -trigger every15
jamf policy -trigger login
jamf policy -trigger startup
etc...
----------
Miles A. Leacy IV
? Certified System Administrator 10.4
? Certified Technical Coordinator 10.5
? Certified Trainer
Certified Casper Administrator
----------
voice: 1-347-277-7321
miles.leacy at themacadmin.com
www.themacadmin.com
Posted on 02-13-2009 02:34 PM
Thanks for your help it works as I have tested it out manually on my
Macbook pro, which doesn't dual boot. So, when we come back to school
on Tuesday and everyone is hitting the network I should get a full
report of how many machines do not have windows.
Dummy packages are very neat idea.