Here is a solution so that a user clicks on the Scripts menu in the menu bar and selects a script from a drop down menu called Reset Firefox.
A pop-up dialog box asks the user 'Do you wish to reset Firefox,' with Yes and No buttons. The user clicks Yes and another dialog pops up 'Just leave the script to do its stuff. Firefox will open with instructions on how to restore your Bookmarks.' with an OK button.
The user clicks OK and waits, and after a short period, Firefox opens as a new user would see it asking the normal setup questions like do you wish to import anything, set the default browser, etc. Then a web page automatically opens which is a Mozilla KB article telling them how to reset their bookmarks.
How to set it up:
- Open Terminal and elevate user privileges to a local admin account if already not.
su admin
- Elevate user privileges to root.
sudo su
- Navigate to or create the directory:
mkdir /Library/Management/Scripts
- Create a script called Reset_Firefox.sh.
touch /Library/Management/Scripts/Reset_Firefox.sh
- Add contents to the script:
vi /Library/Management/Scripts/Reset_Firefox.sh Press key 'i' for insert and insert the following:#!/bin/bash # Quitting Firefox killall firefox-bin # Removing previous Firefox_bookmarkbackups rm -rf ~/Documents/Firefox_bookmarkbackups # Pausing 3 seconds sleep 3 # Making a backup directory mkdir ~/Documents/Firefox_bookmarkbackups # Making a temp direcory mkdir ~/Temp # Pausing 3 seconds sleep 3 # Find the users bookmarkbackups and move them to the temp directory Find -x ~/Library/Application Support/Firefox/Profiles/********.default/ -name 'bookmarkbackups' -print0 | xargs -0 -I bookmarkbackups cp -R bookmarkbackups ~/Temp/ # Pausing 3 seconds sleep 3 # Copy the bookmarkbackups to the Firefox_bookmarkbackups directory cp -R ~/Temp/bookmarkbackups ~/Documents/Firefox_bookmarkbackups/ # Pausing 5 seconds sleep 5 # Deleting the FireFox app data rm -rf ~/Library/Application Support/Firefox # Removing the users Firefox cache rm -rf ~/Library/Caches/Firefox # Pausing 5 seconds sleep 5 # Launch Firefox open /Applications/Firefox.app # Pausing 10 seconds sleep 10 # Moving the bookmarkbackups from the temp to the users new app data location Find -x ~/Library/Application Support/Firefox/Profiles/ -name '********.default' -print0 | xargs -0 -I folder mv ~/Temp/bookmarkbackups/ folder # Pausing 3 seconds sleep 3 # Removing the temp directory rm -rf ~/Temp # Opening the web page for instructions to recover bookmarks open http://kb.mozillazine.org/Backing_up_and_restoring_bookmarks_-_Firefox#Restoring_bookmarks_from_backup /Applications/Firefox.app
- To save the changes press keys 'Shift' and ':' and type wq!.
- Set the permissions on the script so that other users will be able to execute it
chmod -R 775 /Library/Management/
- Package up the script with you favourite packaging tools ready for mass deployment to machines. A good one is Composer by JAMF Software.
- Open up Script editor and paste in the following
display dialog "Do you wish to reset Firefox? You will be able to recover bookmarks following instructions from the opening page." buttons {"No", "Yes"} default button "Yes" if button returned of result is "Yes" then display dialog "Please wait for the script to do its stuff and Firefox should open automatically." if button returned of result is "OK" then do shell script "/Library/Management/Scripts/Reset_Firefox.sh" end if end if - Save the script calling it Reset Firefox to /Library/Scripts/xxx as a run only script, where xxx could be a custom folder name such as your company name, or simply 'Firefox.' It is advisable to keep an editable copy of the script for your reference only calling it Editable_Reset_Firefox and save it somewhere else.
- Change permissions so that all user can execute the AppleScript as before doing it through terminal as root (where xxx is the name you used in the previous step):
Chmod -R 775 /Library/Scripts/xxx/
- Package up the script with you packaging tools ready for mass deployment to machines.
One problem is you need the Scripts menu showing in every users screen on all the machines in the company. To do this we use mcx with Apples Workgroup manager.
Open AppleScript Editor and go to Preferences and tick the box 'Show scripts menu in the Menu bar.'
Navigate to your Preferences directory and copy the file com.apple.systemuiserver.plist to your desktop and using Property list editor (which comes with Apple's Developer Tools) open it and make sure you have under the menuExtras key the entry /System/Library/CoreServices/Menu Extras/Script Menu.menu and save it.
Add the com.apple.systemuiserver.plist to all Computer Groups in Workgroup Manager and when importing it select always.
Next time the machines reboot it will be in the users Menu bar always and you can just publish simple instructions on your company's intranet. This way if a user has a problem just point them to the Intranet page and let them do it.
[crarko adds: I haven't tested this one. Obviously this is targeted to enterprise deployment and it's complete overkill to do all of this for just a few machines. Still, it's good to see hints sometimes aimed at the large-scale network. If it were me, I'd skip the steps using vi and create the script using BBEdit or TextWrangler.
P.S. This was a very complex hint to edit so if there are errors please let me know in the comments so I can fix them.]

