2019-06-15 23:02:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
|
|
|
|
2019-11-02 03:54:42 +00:00
|
|
|
if [ ! -f $QUICKSYNC_UPLOAD_RATE_FILE ]; then
|
|
|
|
UPLOAD_RATE=1000
|
|
|
|
if [ $IS_RASPI3 -eq 1 ]; then
|
|
|
|
UPLOAD_RATE=0
|
|
|
|
fi
|
|
|
|
echo "$UPLOAD_RATE" > $QUICKSYNC_UPLOAD_RATE_FILE
|
|
|
|
else
|
|
|
|
UPLOAD_RATE=$(cat $QUICKSYNC_UPLOAD_RATE_FILE)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f $QUICKSYNC_BACKGROUND_DOWNLOAD_RATE_FILE ]; then
|
2019-11-09 15:32:19 +00:00
|
|
|
DOWNLOAD_RATE=1000
|
2019-11-02 03:54:42 +00:00
|
|
|
if [ $IS_RASPI3 -eq 1 ]; then
|
|
|
|
DOWNLOAD_RATE=500
|
|
|
|
fi
|
|
|
|
echo "$DOWNLOAD_RATE" > $QUICKSYNC_BACKGROUND_DOWNLOAD_RATE_FILE
|
|
|
|
else
|
|
|
|
DOWNLOAD_RATE=$(cat $QUICKSYNC_BACKGROUND_DOWNLOAD_RATE_FILE)
|
2019-08-21 02:02:57 +00:00
|
|
|
fi
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Let transmission startup
|
|
|
|
sleep 60s
|
|
|
|
|
2019-08-21 02:02:57 +00:00
|
|
|
# Check transmission is started
|
|
|
|
until transmission-remote -l ; do
|
|
|
|
sleep 60s
|
2019-07-25 02:51:12 +00:00
|
|
|
done
|
|
|
|
|
2019-08-21 02:02:57 +00:00
|
|
|
# Default is download only until we determine state
|
2019-06-15 23:02:44 +00:00
|
|
|
transmission-remote -u 0
|
2019-08-21 02:02:57 +00:00
|
|
|
transmission-remote -D
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2019-08-21 02:02:57 +00:00
|
|
|
# Determine current state
|
2019-06-15 23:02:44 +00:00
|
|
|
while true; do
|
2019-08-20 04:39:10 +00:00
|
|
|
PERCENT=$(transmission-remote -t 1 -i | grep "Percent Done:")
|
2019-07-25 02:51:12 +00:00
|
|
|
if [ -f $UPLOADER_FILE ]; then
|
2019-08-21 02:02:57 +00:00
|
|
|
echo "Marked as uploader, unlimited upload, unlimited download"
|
2019-07-25 02:51:12 +00:00
|
|
|
transmission-remote -U
|
2019-08-21 02:02:57 +00:00
|
|
|
transmission-remote -D
|
2020-02-29 18:07:20 +00:00
|
|
|
transmission-remote -t 1 --peers 5
|
2019-07-25 02:51:12 +00:00
|
|
|
elif [ ! -f "/mnt/hdd/mynode/quicksync/.quicksync_complete" ]; then
|
2019-10-31 02:01:37 +00:00
|
|
|
echo "QuickSync not complete, limited upload, unlimited download"
|
2019-11-02 03:54:42 +00:00
|
|
|
transmission-remote -u $UPLOAD_RATE
|
2019-08-21 02:02:57 +00:00
|
|
|
transmission-remote -D
|
2020-02-29 18:07:20 +00:00
|
|
|
transmission-remote -t 1 --peers 10
|
2019-07-13 23:56:42 +00:00
|
|
|
elif [ ! -f "/mnt/hdd/mynode/.mynode_bitcoind_synced" ]; then
|
2019-08-21 02:02:57 +00:00
|
|
|
echo "Bitcoin not synced, stopping upload, stopping download"
|
2019-07-13 23:56:42 +00:00
|
|
|
transmission-remote -u 0
|
2019-08-21 02:02:57 +00:00
|
|
|
transmission-remote -d 0
|
2019-08-20 04:39:10 +00:00
|
|
|
elif [[ "$PERCENT" != *"100"* ]]; then
|
2019-10-31 02:01:37 +00:00
|
|
|
echo "QuickSync is downloading (but has completed once), limited upload, limited download"
|
2019-11-02 03:54:42 +00:00
|
|
|
transmission-remote -u $UPLOAD_RATE
|
|
|
|
transmission-remote -d $DOWNLOAD_RATE
|
2019-06-15 23:02:44 +00:00
|
|
|
else
|
2020-02-29 18:07:20 +00:00
|
|
|
echo "Setting upload rate for stable state"
|
|
|
|
transmission-remote -u $UPLOAD_RATE
|
|
|
|
transmission-remote -d $DOWNLOAD_RATE
|
|
|
|
transmission-remote -t 1 --peers 5
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
2019-08-21 02:02:57 +00:00
|
|
|
sleep 10m
|
2019-06-15 23:02:44 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# We should not exit
|
|
|
|
exit 1
|