2019-06-15 23:02:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
|
|
|
|
|
|
|
echo "Waiting until QuickSync is complete..."
|
2019-07-07 03:18:19 +00:00
|
|
|
while [ ! -f "$QUICKSYNC_COMPLETE_FILE" ]; do
|
2020-02-12 06:02:35 +00:00
|
|
|
sleep 1h
|
2019-06-15 23:02:44 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
# Wait a while... we don't want everyone starting on a new torrent at once
|
2019-07-25 02:51:12 +00:00
|
|
|
if [ -f $UPLOADER_FILE ]; then
|
2020-02-12 06:02:35 +00:00
|
|
|
echo "Marked as uploader, checking for new torrent..."
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2020-02-12 06:02:35 +00:00
|
|
|
# Download current torrent
|
|
|
|
rm -rf /tmp/blockchain_temp.torrent
|
|
|
|
if [ -f $UPLOADER_FILE ]; then
|
|
|
|
wget -O /tmp/blockchain_temp.torrent $QUICKSYNC_TORRENT_BETA_URL
|
2019-06-15 23:02:44 +00:00
|
|
|
else
|
2020-02-12 06:02:35 +00:00
|
|
|
wget -O /tmp/blockchain_temp.torrent $QUICKSYNC_TORRENT_URL
|
|
|
|
fi
|
|
|
|
if [ -f /tmp/blockchain_temp.torrent ]; then
|
|
|
|
NEW_TORRENT=0
|
|
|
|
cmp --silent /tmp/blockchain_temp.torrent $QUICKSYNC_DIR/blockchain.torrent || NEW_TORRENT=1
|
|
|
|
if [ $NEW_TORRENT -eq 1 ]; then
|
|
|
|
# Reboot to restart and get new torrent
|
|
|
|
reboot
|
|
|
|
else
|
|
|
|
echo "Torrent has not changed."
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Torrent download failed...."
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
|
|
|
fi
|
2020-02-12 06:02:35 +00:00
|
|
|
|
|
|
|
sleep 1d
|
2019-06-15 23:02:44 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Should never exit
|
|
|
|
exit 99
|