|
#!/bin/bash |
|
# Set as many bookmarks in Safari as needed |
|
# Adapted from the script by David Koff, 2012 for the J. Paul Getty Trust |
|
# many thanks to both Chris Norris ([email protected]) & Ryan Manly ([email protected]) for their invaluable input |
|
# https://jamfnation.jamfsoftware.com/discussion.html?id=6031 |
|
|
|
bud='/usr/libexec/Plistbuddy' |
|
plist="/Users/student/Library/Safari/Bookmarks.plist" |
|
urls=('https://testnav.com/mn/testnav-7.5.22.36/' |
|
'https://proctorcaching.pearsonaccess.com/ems/systemCheck/systemCheck.jsp?acc=mn' |
|
'https://www.testnav.com/mn/testnav-7.5.22.36/' |
|
'http://www.pearsonaccess.com/cs/Satellite?c=Page&childpagename=Minnesota%2FmnPALPLayout_v2&cid=1205797559436&p=1205797559436&pagename=mnPALPWrapper&itemsamplercategory=Online+Item+Samplers&start=20') |
|
|
|
echo "Backing up ${plist}..." |
|
cp ${plist} ${plist}.orig |
|
#rm ${plist} |
|
|
|
killall cfprefsd > /dev/null |
|
for i in "${!urls[@]}" |
|
do |
|
# Strip just the domain name from the url so it can be used in the case statement to create a bookmark name |
|
domain=$(echo ${urls[$i]} | cut -d'/' -f3) |
|
${bud} -c "Add :Children:1:Children:$i dict" ${plist} |
|
${bud} -c "Add :Children:1:Children:$i:URIDictionary dict" ${plist} |
|
# For each domain, add a line that creates the title you want |
|
# Be sure to escape whitespace in the name |
|
case $domain in |
|
testnav.com) ${bud} -c "Add :Children:1:Children:$i:URIDictionary:title string TestNav\ Test" ${plist};; |
|
proctorcaching.pearsonaccess.com) ${bud} -c "Add :Children:1:Children:$i:URIDictionary:title string TestNav\ Check" ${plist};; |
|
www.testnav.com) ${bud} -c "Add :Children:1:Children:$i:URIDictionary:title string TestNav\ Test\ 2" ${plist};; |
|
www.pearsonaccess.com) ${bud} -c "Add :Children:1:Children:$i:URIDictionary:title string TestNav\ Samplers" ${plist};; |
|
# If there is not match, the bookmark name will just be the domain name |
|
*) ${bud} -c "Add :Children:1:Children:$i:URIDictionary:title string $domain" ${plist};; |
|
esac |
|
# The actual URL is added here |
|
${bud} -c "Add :Children:1:Children:$i:URLString string ${urls[$i]}" ${plist} |
|
${bud} -c "Add :Children:1:Children:$i:WebBookmarkType string WebBookmarkTypeLeaf" ${plist} |
|
done |
|
|
|
# I find that reading the plist with defaults helps the settings apply on Mavericks and Yosemite machines |
|
echo "Applying all settings..." |
|
defaults read ${plist} >/dev/null |
|
# Repair permissions when running as root |
|
chown student ${plist} |