#!/bin/zsh

if [ $# -lt 1 ]; then
  echo 1>&2 "$0: must supply ssh port numbers of devices to update, e.g. 10873, 12873, etc."
  echo 1>&2 "$0 10873 12873 15873"
  exit 2
fi

for port in "$@"
do
        echo "Copying roots to port: $item"
        RSYNC_PASSWORD=alpine rsync -av /tmp/securitysoscircle.roots.tgz rsync://root@localhost:$port/root/var/mobile/
        RSYNC_PASSWORD=alpine rsync -av ~/bin/sosinstallroot rsync://root@localhost:$port/root/usr/local/bin/sosinstallroot
done

udids=( 79003b34516ba80b620e3d947e7da96e033bed48 96476595e5d0ef7496e8ff852aedf4725647960b )
 
for U in $udids
do
	echo "updating device $U"
        PurpleExec --target $U /usr/local/bin/mobile_install rebuild internal
        PurpleExec --target $U chmod +x /usr/local/bin/sosinstallroot
	PurpleExec --target $U script /var/log/myscript.log /usr/local/bin/sosinstallroot
done

