接续前篇的<OSX: 不要升级到ARD 3.7.1 Admin>, 如果也不想<OSX: ARD Admin的降级>, 那么可以使用Bryan Pietrzak写的脚本来临时解决3.7.1带来的各种问题。据Bryan的分析和实践,3.7.1的各种问题,都是因为3.7.1处理IP地址和DNS名称所导致的。
具体点说,每当ARD找到一个新的机器后,就会把该机器的信息缓存在名为com.apple.RemoteDesktop.plist的plist文件中,其中就有最初该机器的IP和DNS名。不过问题是,绝大多数的网络环境都使用DHCP来动态给主机分配一个具有有效期的地址,过期后机器重新申请一个IP,可能就是另外一个IP了。3.7.1中的处理似乎是没有很好地处理一个主机可能被缓存多个IP的情况。
在3.6.2的版本中,它的记录信息如下,可以看见同一个电脑有多个IP记录。
其实3.6.x中,对于一个电脑同时有两个IP的情况,处理也会出现问题,有时延时很长时间或者无法确认连接和管理。这个问题在3.7.1中同样存在。
就目前的经验来说,3.5.3是最稳定,反应最快的版本。
下面是该脚本,原版连接地址:https://gist.github.com/bryanzak/9065400。Bryan的网络环境是,DHCP的租用时间14天,他每个星期运行一次来清理,收到比较好的效果。
#!/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