#!/bin/zsh roots="/tmp/security.roots.tgz" syms="/tmp/security.syms.tgz" srcs="/tmp/security.src.tgz" sshopts=(-o CheckHostIP=no -o StrictHostKeyChecking=no -o NoHostAuthenticationForLocalhost=yes -o UserKnownHostsFile=/dev/null) locations=(`mobdev list | awk '/UDID/ { gsub(/^(.*location ID = )+|(,.*)+$/, ""); print}'`) port_offset=20000 symdir="/var/mobile/secsyms" for location in $locations do echo 'Installing to location '"$location" tcprelay --portoffset $port_offset --locationid $location ssh >/dev/null 2>&1 & (( sshport = $port_offset + 22 )) echo "Copying roots to device (via port $sshport)" scp -P $sshport $sshopts $roots $syms $srcs root@localhost:/var/mobile/ echo "SSH to device and do commands" ssh $sshopts -p $sshport root@localhost << END /bin/hostname /sbin/mount -uw / /usr/local/bin/darwinup install "/var/mobile/`basename $roots`" | grep -v '^ /' /usr/local/bin/darwinup uninstall superseded > /dev/null 2>&1 || true touch /System/Library/Caches/com.apple.xpcd/xpcd_cache.dylib /usr/local/bin/mobile_install rebuild internal /bin/launchctl stop com.apple.securityd /bin/launchctl stop com.apple.security.cloudkeychainproxy3 /bin/launchctl stop com.apple.security.CircleJoinRequest END kill -HUP %% done