Created
January 7, 2016 02:36
-
-
Save calum-github/69c292d5312d3f523e0e to your computer and use it in GitHub Desktop.
post-install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: Calum Hunter | |
# Date: 06/01/2016 | |
# Version: 0.2 | |
# | |
# Post-install for Chrome Preferences | |
# Copy the Chrome template into the | |
# System User Template | |
# | |
# We should also check for existing users on the system | |
# that might have fallen through the gaps. | |
# If they do not already have a Google Chrome Profile/Template | |
# Then create one and copy our preferences in to it | |
# Where is our generic template | |
chrome_template="/Library/Scripts/YOUR_ORG_NAME/Google/Chrome" | |
# Get a list of our users in /Users - ignore some folders that are not user accounts | |
Users=($(find /Users -maxdepth 1 | grep -v -e ".localized" -e "Shared" -e "Deleted Users" -e ".DS_Store" | tail +2 | awk -F "/" '{print $3}')) | |
# Test if we have the Google Chrome folder already, if not create it. | |
if [ ! -d "/System/Library/User Template/English.lproj/Library/Application Support/Google/Chrome" ]; then | |
mkdir -p "/System/Library/User Template/English.lproj/Library/Application Support/Google/Chrome" | |
fi | |
# Copy our template into our User Template | |
cp -R /Library/Scripts/YOUR_ORG_NAME/Google/Chrome "/System/Library/User Template/English.lproj/Library/Application Support/Google/" | |
# Set the permissions appropriately | |
chown -R root:wheel "/System/Library/User Template/English.lproj/Library/Application Support/Google" | |
chmod 755 "/System/Library/User Template/English.lproj/Library/Application Support/Google" | |
# Loop through our users, looking for existing google folder, create it if it doesn't exist | |
for P in "${Users[@]}" | |
do | |
if [ ! -d "/Users/$P/Library/Application Support/Google/Chrome" ]; then | |
mkdir -p "/Users/$P/Library/Application Support/Google/Chrome" | |
cp -R $chrome_template "/Users/$P/Library/Application Support/Google/" | |
chown -R $P "/Users/$P/Library/Application Support/Google" | |
chmod -R 755 "/Users/$P/Library/Application Support/Google" | |
else | |
echo "User already has a Google Chrome folder, assuming they have already have a profile, no need to do anything" | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment