Scripting remove files

dbarnaby
New Contributor

I am new to Mac and Jamf.

When our MacBooks were imaged the Spotlight stopped working. I found the problem is i need to remove a file from the root named .metedata_never_index and restart the indexer

I am attempting to wright a script to use with the self service portal. If they have the problem they can just run it from there.
Script
#!/bin/sh
#
sudo rm /.metedata_never_index
sudo mdutil -i on /
Script end

I think i need to run this as root, this is why i used sudo command but it asks for password and if i run it from self service it dose not prompt me for password. I have a hidden account on all the mac's named tech that is an admin account, can i use that account to run under or can i just have the user be prompted for there password.

Is this the best way to do this?

1 ACCEPTED SOLUTION

john_miller
Contributor

Hey dbarnaby!

Thanks for posting and welcome!

All Self Service items are a policy, and all policies run as root. Removing the "sudo" from the command, then uploading the script to Casper Admin and executing the policy should see it run without prompting for the credentials.

I hope this helps!

View solution in original post

2 REPLIES 2

john_miller
Contributor

Hey dbarnaby!

Thanks for posting and welcome!

All Self Service items are a policy, and all policies run as root. Removing the "sudo" from the command, then uploading the script to Casper Admin and executing the policy should see it run without prompting for the credentials.

I hope this helps!

Chris_Hafner
Valued Contributor II

This has been posted about previously. Several users/JAMF staff submitted the following

#!/bin/sh
rm /.metadata_never_index
rm /.fseventsd/no_log

Run this and you'll be 100% As far as my testing goes this issue seems to be resolved in Casper Imaging 8.62