Posted on 06-12-2018 07:46 AM
Good morning,
I've been beating my head against the wall trying to find a solution to this, so I'm hoping that the Jamfnation "hive mind" might have a solution: I need to set the homepage for Firefox, Chrome and Safari via a script (or some way that can be deployed post-image.)
Here's the situation: After we image our student laptops with DeployStudio (yes, I know, imaging is dead...but that's what we have right now,) DeployStudio appears to "sanitize" the image, which causes us to lose the homepages we set on the "master," from which the image was created. We'd like to set the homepages so that new students get familiar with our "logins" page, which is where they'll start when accessing our online resources. We don't necessarily want to "lock" the homepages, just to initially set them - and doing so via a script (or a package/payload-free package) that can be run during post-image in DeployStudio would be ideal.
What seems like a simple task has proven fairly difficult to accomplish. I've found many old ways of doing it that no longer work, or ways that set the homepage but then prevent it from being changed. If anyone out there has any insight into what might work, I would love to hear it.
Posted on 06-12-2018 07:56 AM
Each of the browsers are different unfortunately.
Chrome can be managed via a custom config profile, Safari used to be able to, although some people have said it isn't working any longer, and firefox needs a custom setting added to the app bundle with CCK2.
Here's some useful guides / links:
Posted on 06-12-2018 02:46 PM
if [[ ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-50
== "00000000-0000-1000-8000-" ]]; then
MAC_UUID=ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c51-62 | awk {'print tolower()'}
elif [[ ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-50
!= "00000000-0000-1000-8000-" ]]; then
MAC_UUID=ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-62
fi
sudo killall -z -m "Safari" -signal
localUsers=$( dscl . list /Users UniqueID | awk '$2 >= 501 {print $1}' | grep -v admin )
defaults write /System/Library/User Template/English.lproj/Library/Preferences/com.apple.Safari.plist HomePage https://apolloedu.sharepoint.com/sites/PhoenixView/
echo "$localUsers" | while read userName; do
mv /Users/$userName/Library/Keychains/$MAC_UUID/keychain-2.db /Users/$userName/Library/Keychains/$MAC_UUID/keychain-2.dbBKUP 2> /dev/null
defaults write /Users/$userName/Library/Preferences/com.apple.Safari.plist HomePage https://apolloedu.sharepoint.com/sites/PhoenixView/
defaults write /Users/$userName/Library/Safari/LastSession.plist TabURL https://apolloedu.sharepoint.com/sites/PhoenixView/
chown $userName /Users/$userName/Library/Preferences/com.apple.Safari.plist
sleep 3
mv /Users/$userName/Library/Safari/LastSession.plist /Users/$userName/Library/Safari/LastSession.plistBKUP
chmod 644 /Users/$userName/Library/Safari/LastSession.plistBKUP
chown -R $userName:"APOLLOGROUPDomain Users" /Users/$userName/Library/Safari/LastSession.plistBKUP
sudo killall Firefox.app
localUsers=$( dscl . list /Users UniqueID | awk '$2 >= 501 {print $1}' | grep -v admin )
ffold=(http://arc.apollogrp.edu)
ffnew=(https://apolloedu.sharepoint.com/sites/PhoenixView)
sed -i .bak 's|'$ffold'|'$ffnew'|g' /usr/local/storage/Firefox/Profiles/lsbasfxf.default/prefs.js
sed -i .bak 's|'$ffold'|'$ffnew'|g' /System/Library/User Template/English.lproj/Library/Application Support/Firefox/Profiles/lsbasfxf.default/prefs.js
echo "$localUsers" | while read userName; do
sed -i .bak 's|'$ffold'|'$ffnew'|g' /Users/$userName/Library/Application Support/Firefox/Profiles/lsbasfxf.default/prefs.js
sudo killall -z -m "Google Chrome"
localUsers=$( dscl . list /Users UniqueID | awk '$2 >= 501 {print $1}' | grep -v admin )
ffold=(http://arc.apollogrp.edu)
ffnew=(https://apolloedu.sharepoint.com/sites/PhoenixView)
defaults write /System/Library/User Template/English.lproj/Library/Preferences/com.google.Chrome.plist HomepageLocation -string https://apolloedu.sharepoint.com/sites/PhoenixView/
defaults write /System/Library/User Template/English.lproj/Library/Preferences/com.google.Chrome.plist RestoreOnStartupURLs -array https://apolloedu.sharepoint.com/sites/PhoenixView/
sed -i .bak 's|'$ffold'|'$ffnew'|g' /System/Library/User Template/English.lproj/Library/Application Support/Google/Chrome/Default/Preferences
echo "$localUsers" | while read userName; do
sed -i .bak 's|'$ffold'|'$ffnew'|g' /Users/$userName/Library/Application Support/Google/Chrome/Default/Preferences
defaults write /Users/$userName/Library/Preferences/com.google.Chrome.plist HomepageLocation -string https://apolloedu.sharepoint.com/sites/PhoenixView/
defaults write /Users/$userName/Library/Preferences/com.google.Chrome.plist RestoreOnStartupURLs -array https://apolloedu.sharepoint.com/sites/PhoenixView/
chmod 755 /Users/$userName/Library/Preferences/com.google.Chrome.plist
chmod 755 /Users/$userName/Library/Preferences/com.google.Keystone.Agent.plist
sleep 2
chown $userName:wheel /Users/$userName/Library/Preferences/com.google.Chrome.plist
chown $userName:wheel /Users/$userName/Library/Preferences/com.google.Keystone.Agent.plist
dscl . -mcxdelete /Computers/localhost com.google.Chrome
mcxrefresh -n $userName
done
Posted on 06-14-2018 06:37 AM
Thank you for your responses! I'm hoping to try these later today - I apologize for the delay in responding - got pulled into a different project temporarily.
Posted on 08-26-2018 02:48 PM
@jkarpenske did you get a chance to try this if so what were your results? I tried to run parts of the script manually before setting a script in jamf and didn't have success setting the homepage.
Posted on 08-27-2018 03:00 AM
The jamf Binary also has a Build in Option to set the Homepage for Safari and Firefox
Usage: jamf setHomePage -homepage <homepage> [-feu] [-fut] [-username <username>]
[-removeDownloadLocation] [-skipIE] [-skipFirefox] [-skipMozilla] [-skipSafari]
-homepage The URL for the homepage
-feu Set the homepage for existing users
-fut Set the homepage in the User Templates
-username Set the homepage only for this user
-ffmstone Specify the milestone version for FireFox
-mozmstone Specify the milestone version for Mozilla (Netscape)
-removeDownloadLocation Remove the default download location
-skipIE Do not set the homepage for Internet Explorer
-skipFirefox Do not set the homepage for Firefox
-skipMozilla Do not set the homepage for Mozilla based browsers (Netscape)
-skipSafari Do not set the homepage for Safari
Posted on 08-27-2018 05:55 AM
@claudiogardini That was one of the first things I tried. This did not work for Safari but did work for Firefox and doesn't help for Chrome. For reference we are on MacOS 10.13, Safari 11.0.2, FF 61.0.2, and Chrome 68.
Edit: Managed to get Chrome working via notes https://www.jamf.com/jamf-nation/discussions/23233/google-chrome-homepage
Posted on 08-27-2018 12:51 PM
On of my philosophies is when Jamf feature is broken.. I like to think why? And since "jamf setHomePage -homepage" has worked on again off again for years and years (over 8 years). A few years back I decided that it was Apple didn't want anybody changing Safari home page...that empower me to "convince" my "management" that if Apple doesn't want it then we really shouldn't be doing it ... and then in that same discussion I asked why? It came down to none of the macOS user were hitting the home page so the "stats looked bad" Then I pointed out that the macOS stats were the true users stats of the our home page... that ended the discussion and topic...
C
PS IF you have a web page that the user really need to visit and it's a complicate URL you can alway use self service too!!!
Posted on 09-11-2018 02:16 PM
Has anyone tested @Cornoir scripts yet, I have been looking for anything to making this a little more stream lined and have looking at most of the relevant post pertaining to this. I have also tried jamf setHomePage for Firefox 62.0, Safari 11.1.2, Chrome 69.0
Posted on 09-12-2018 01:45 PM
Not sure this will help but it's the last "trick" I had working before I gave up..
https://managingosx.wordpress.com/2015/02/02/command-line-tools-via-python-and-cocoa/
C
Posted on 04-17-2019 03:15 AM
@claudiogardini This was working for me today with macOS Mojave and Firefox 66.0!
sudo jamf setHomePage -homepage https://www.google.com -feu -fut -skipIE -skipSafari
Posted on 01-28-2020 08:35 PM
For Safari, check out my post here.
Posted on 12-07-2020 01:33 PM
Hi
Does anyone have working .plist for firefox homepage?
I got the safari and chrome to work , but no luck with firefox!
many thanks in advance!!!