Created
August 18, 2018 23:49
-
-
Save MariMax/581c85192edbb817330bd7e731ffe888 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin | |
policies_store="/Library/Managed Preferences" | |
users_dir="/Users" | |
policies="com.google.Chrome.plist com.google.Keystone.Agent.plist com.apple.icloud.managed.plist com.apple.preferences.users.plist" | |
##################################################### | |
script_name=`basename $0` | |
current_date=`date` | |
users_dir_basename=`basename ${users_dir}` | |
current_user=`find /${users_dir} -maxdepth 1 -type d -exec basename {} \; | grep -v ${users_dir_basename} | grep -v Shared` | |
user_count=`echo ${current_user} | wc -w | xargs` | |
if [[ "${user_count}" -gt "2" ]] ; then | |
echo "More than 1 user found... Terminating..." | |
exit | |
fi | |
echo "Running ${script_name} at: ${current_date}" | |
echo "Force disable policy for Chrome even if already disabled..." | |
defaults write com.google.Chrome EnableCommonNameFallbackForLocalAnchors -bool false | |
for policy in ${policies}; do | |
policy_file_exist=`ls "${policies_store}/${policy}" 2>/dev/null | wc -l | xargs` | |
user_policy_file_exist=`ls "${policies_store}/${current_user}/${policy}" 2>/dev/null | wc -l | xargs` | |
if [[ "${policy_file_exist}" = "1" ]] || [[ "${user_policy_file_exist}" = "1" ]]; then | |
echo "Wipe policy ${policy}" | |
rm -rf "${policies_store}/${policy}" "${policies_store}/${current_user}/${policy}" | |
fi | |
done | |
echo "${script_name} finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment