-
Notifications
You must be signed in to change notification settings - Fork 1
/
sync.sh
executable file
·29 lines (24 loc) · 924 Bytes
/
sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
cd "$(dirname "$0")"
exec > $SERIAL.log
exec 2>&1
timeout 5 adb -s $SERIAL wait-for-device || exit 1
adb -s $SERIAL shell cp /sdcard/rsync.bin /data/local/tmp/rsync &&
adb -s $SERIAL shell chmod 755 /data/local/tmp/rsync &&
adb -s $SERIAL shell -x '/data/local/tmp/rsync --daemon --config=/sdcard/rsyncd.conf --log-file=/proc/self/fd/2'
adb -s $SERIAL forward tcp:6010 tcp:1873
# Wait for rsync daemon to be ready (10s timeout)
until rsync -n rsync://localhost:6010 > /dev/null || ((i++ >= 100)); do
sleep .1
done
(
rsync -rt --progress --no-inc-recursive "rsync://localhost:6010$SOURCE" "$DEST" |
awk -f rsync.awk |
zenity --progress --title "Synchronizing files..." --time-remaining \
--text="Scanning..." --percentage=0 --auto-close --auto-kill
exit ${PIPESTATUS[0]}
)
if [ "$?" != 0 ]; then
zenity --error --text="Synchronization failed or canceled" &
fi
adb -s $SERIAL shell pkill rsync