Posted on 11-14-2013 07:03 AM
Hi,
Found a variant of Minecraft that puts an invisible folder at the root of the local AD users home folder. It creates a folder called ".minecraft". I am not very good at scripts, and I don't want to accidentally screw things up.
I know you can do a path to a file in a policy, but am not sure how to do that for every local AD user account.
So just asking for peoples best practice to do away with this file.
Thanks!
Solved! Go to Solution.
Posted on 11-14-2013 07:26 AM
#!/bin/sh
rm -rf /Users/*/.minecraft
That would cover it safely, I'd say. Maybe run in a policy once per day
~Andrew
Posted on 11-14-2013 07:08 AM
@steventhemacman, try this:
Posted on 11-14-2013 07:12 AM
Ooh, I like that.
Posted on 11-14-2013 07:26 AM
#!/bin/sh
rm -rf /Users/*/.minecraft
That would cover it safely, I'd say. Maybe run in a policy once per day
~Andrew
Posted on 11-14-2013 07:27 AM
Ooh, I like that more.
Posted on 11-14-2013 07:40 AM
Unfortunately bentoms policy didn't work...I wonder if it is because it is a invisible folder. Not sure. I triple checked everything, the policy runs, but the folder is still there...I will try the script from vadanx next....
Posted on 11-14-2013 09:01 AM
You can always set their volume to 10 and use a SAY command to alert them that Minecraft should not be installed on your equipment. That tends to drive the point home...for awhile.
Posted on 11-14-2013 09:14 AM
Because Minecraft is a drag and drop install,why not just disallow any process named Minecraft? If it can't start, it can't dump those folders.
Check out restricted software to limit the use of this app.
Posted on 11-14-2013 09:16 AM
.jar file and squashing it has caused us issues with our EOC browser and other programs.
Posted on 11-14-2013 10:24 AM
You can always set their volume to 10 and use a SAY command to alert them that Minecraft should not be installed on your equipment. That tends to drive the point home...for awhile.
Maybe the best solution I've read in a while :)
Or, I'm sick like you!
Posted on 11-14-2013 02:57 PM
i like the volume suggestion :)
In practice the wildcard has not always worked for me when running through Casper remote or policy. For some reason the wildcard is not always expanded by the shell.
To that end I've written a boiler plate script that loops through every home directory and performs operations that need to occurr on every existing user. At the end I do whatever it is I need to do to the user template and voila!
Posted on 11-15-2013 11:26 AM
I am running open directory on mountain lion server. I need to delete every users firefox profile due to corruption. I am a complete newbie when it comes to scripts. Will these commands work for me through terminal, as long as I point it to the correct directory?
Posted on 11-15-2013 11:26 AM
I am running open directory on mountain lion server. I need to delete every users firefox profile due to corruption. I am a complete newbie when it comes to scripts. Will these commands work for me through terminal, as long as I point it to the correct directory?
Posted on 11-15-2013 11:27 AM
I am running open directory on mountain lion server. I need to delete every users firefox profile due to corruption. I am a complete newbie when it comes to scripts. Will these commands work for me through terminal, as long as I point it to the correct directory?
edit: Sorry about the multiple posts
Posted on 11-15-2013 11:45 AM
Do you have network home profiles? Or local to the Mac?
If local to the Mac;
rm -rf /Users/*/Library/Application Support/Firefox
Would cover that, but always practise a script in as close to the environment that it's going to be used in. You could test it with Firefox launched and quit to see if it creates the desired effect you want and expect.
Posted on 11-15-2013 11:45 AM
Do you have network home profiles? Or local to the Mac?
If local to the Mac;
rm -rf /Users/*/Library/Application Support/Firefox
Would cover that, but always practise a script in as close to the environment that it's going to be used in. You could test it with Firefox launched and quit to see if it creates the desired effect you want and expect.
Posted on 11-15-2013 11:53 AM
They are network. my path would be
/DataHD/Usershome
So would
rm -rf /DataHD/Usershome/*/Library/Application Support/Firefox
be the proper usage?
Posted on 11-15-2013 07:31 PM
I have restriced software set to block "Minecraft" processes, but it does not seem to work, hence my post. Not sure why it isn't working...but the simple command from vadanx seems to be working great.
Posted on 11-16-2013 01:15 AM
@steventhemacman. Glad you got it working. I was trying to find a non-scripting way!
Posted on 11-18-2013 01:50 AM
Good to see it's working. More often than not the simplest solutions tend to be the best, as long as it doesn't create additional headaches. :)
Posted on 11-18-2013 12:27 PM
Hey Everyone,
Just my 2 cents here. Using wild cards in scripts could end up in undesired results. Also, when looking at mass deleting files from end users or even file shares on servers I typically like to get some sort of report going first before I pull the 'delete-trigger.' The find binary is perfect for this. I did also try spotlight's binary (mdfind) but it had trouble finding hidden files, the dot file names. I am thinking Spotlight on purpose does not index hidden files.
So, I would maybe build an extension attribute like so:
#!/bin/bash
# find .minecraft and report on it
currentUser=$(ls -l /dev/console | awk '{ print $3}')
# find the file we are looking for
badFile=$(find /Users/${currentUser} -name '.minecraft' -print)
if [[ -e ${badFile} ]]
then echo "<result>has minecraft</result>"
fi
Then, later on scope out a smart group based on the EA to remove it, by sending out a script on one of your every triggers.
#!/bin/bash
# find .minecraft and report on it
currentUser=$(ls -l /dev/console | awk '{ print $3}')
# find the file we are looking for
badFile=$(find /Users/${currentUser} -name '.minecraft' -print)
if [[ -e ${badFile} ]]
then rm -rf ${badFile}
fi
exit 0
example output of the delete script:
$ bash -x rm_minecraft.sh
++ ls -l /dev/console
++ awk '{ print $3}'
+ currentUser=tlarkin
++ find /Users/tlarkin -name .minecraft -print
+ badFile=/Users/tlarkin/.minecraft
+ [[ -e /Users/tlarkin/.minecraft ]]
+ rm -rf /Users/tlarkin/.minecraft
+ exit 0
Using the '-print' switch with the find command will allow you to report on this first. Even though it may be unlikely, but someone may make a legit file called "minecraft," and wild carding the commands could delete that file as well. Like, perhaps if a student was writing a paper on that topic. Also, reporting on it allows you to take those reports to those in charge. When I worked for the K12 educational system, I typically never did anything other than build reports and hand them over to the administration for them to decide what to do. If an admin requested I remove files/software I instead built a report in the JSS and emailed it to them so they could decide what to do. This is just my personal experience and I know every K12 environment is different.
Thanks,
Tom
Posted on 07-31-2020 01:01 AM
Bringing an old thread to life here, but since this was one of the first results that poped up when googling the issue I thought an update could be useful for any other who have the same question.
I managed to get this working by using the following script:
#!/bin/sh
#Get current logged in user
USER=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
#Delete the file
sudo -u $USER rm /Users/$USER/the/rest/of/the/path.filetype
exit 0
Worth noting here is that if you use ~ instead of /Users/$USER/ the script only succeeds when run as a Self Service policy. If using any other trigger the script fails since it tries to run in the root-directory instead.
Posted on 01-04-2021 01:35 PM
@tlarkin I like the approach you are using, but I'm not getting the results in my EA. Im thinking the echo command isn't quite working since the rest of the script seems to function. I updated the get current user command and switched to using the mdfind since its not an invisible file and finds it quite quickly but im just not getting any results with it. I'd actually like to get this working because then I can modify it to work with loads of files. See below:
#!/bin/bash
# find RobloxStudio.dmg and report on it
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{print $3}')
# find the file we are looking for
badFile=$(mdfind -onlyin /Users/${currentUser} -name 'RobloxStudio.dmg')
if [[ -e ${badFile} ]]
then echo "<result>has RobloxStudio</result>"
fi
Gabe Shackney
Princeton Public Schools
Posted on 01-04-2021 02:29 PM
@gshackney Try this for your EA:
#!/bin/bash
fileToFind="RobloxStudio.dmg"
# find RobloxStudio.dmg and report on it
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{print $3}')
# find the file we are looking for
badFile=$(mdfind -onlyin /Users/${currentUser} -name "$fileToFind")
if [[ -n ${badFile} ]]; then
echo "<result>Has $fileToFind</result>"
else
echo "<result>Not found</result>"
fi
The mdfind
command can return multiple results, so the -e
won't necessarily work. The -n
checks to see if it returns anything. Note that it'll also return a hit on "NotRobloxStudio.dmg"