Last active
March 3, 2017 05:36
Revisions
-
bryanzak renamed this gist
Feb 18, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
bryanzak created this gist
Feb 18, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,90 @@ #!/bin/bash SCRIPT_VERSION="1.0" # some background info here: https://discussions.apple.com/message/24596710#24596710 # verify ARD Admin version # quit ARD Admin - if running, wait 10 seconds # kill cfprefsd # rename plist # sed plist_path="$HOME/Library/Containers/com.apple.RemoteDesktop/Data/Library/Preferences" plist_name="com.apple.RemoteDesktop.plist" plist_backup="com.apple.RemoteDesktop-backup.plist" VerfiyARDAdmin() { if [ -d "/Applications/Remote Desktop.app" ]; then version=$(defaults read "/Applications/Remote Desktop.app/Contents/Info" CFBundleVersion) major_version=$(echo "$version" | cut -d. -f1) minor_version=$(echo "$version" | cut -d. -f2) bugfix_version=$(echo "$version" | cut -d. -f3) if [[ "$major_version" == "3" ]] && [[ "$minor_version" == "7" ]] && [[ "$bugfix_version" == "1" ]]; then echo "Remote Desktop Admin 3.7.1 installed, proceeding to fix...." else echo "### ERROR: Remote Desktop Admin $version installed. Requires 3.7.1..." exit 1 fi else echo "### ERROR: Remote Desktop Admin not installed" exit 1 fi } QuitARD() { app="Remote Desktop" ignore=$(ps -A | egrep -i "$app" | grep -v grep) isopen=$? if [ $isopen != 1 ]; then { echo "Quitting Remote Desktop..." osascript -e "tell application \"Remote Desktop\"" -e 'quit' -e 'end tell' sleep 15 # give cfprefsd enough time to flush the the preferences } fi } QuitCFPrefsDaemon() { echo "Quitting CFPrefs Caching Daemon..." killall cfprefsd } ProcessPList() { echo "Backing up Remote Desktop plist..." cd "$plist_path" mv -f "$plist_path/$plist_name" "$plist_path/$plist_backup" echo "Converting plist to XML...." plutil -convert xml1 "$plist_path/$plist_backup" echo "Editing Remote Desktop plist..." pattern1="<key>hostname<\/key>/<key>blah_1<\/key>" pattern2="<key>hostnames<\/key>/<key>blah_2<\/key>" pattern3="<key>networkAddress<\/key>/<key>blah_3<\/key>" pattern4="<key>networkAddresses<\/key>/<key>blah_4<\/key>" pattern5="<key>primaryIdentfier<\/key>/<key>blah_5<\/key>" sed "s/$pattern1/g;s/$pattern2/g;s/$pattern3/g;s/$pattern4/g;s/$pattern5/g" "$plist_path/$plist_backup" > "$plist_path/$plist_name" echo "Converting plist to binary...." plutil -convert binary1 "$plist_path/$plist_name" } clear VerfiyARDAdmin QuitARD QuitCFPrefsDaemon ProcessPList exit 0