2019-06-15 23:02:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
|
|
|
|
2019-08-22 03:15:23 +00:00
|
|
|
BACKGROUND_DL_RATE=2500
|
2019-08-21 02:02:57 +00:00
|
|
|
if [ $IS_RASPI3 -eq 1 ]; then
|
|
|
|
BACKGROUND_DL_RATE=500
|
|
|
|
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
|
2019-07-25 02:51:12 +00:00
|
|
|
elif [ ! -f "/mnt/hdd/mynode/quicksync/.quicksync_complete" ]; then
|
2019-08-21 02:02:57 +00:00
|
|
|
echo "QuickSync not complete, stopping upload, unlimited download"
|
2019-07-13 23:56:42 +00:00
|
|
|
transmission-remote -u 0
|
2019-08-21 02:02:57 +00:00
|
|
|
transmission-remote -D
|
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-08-21 02:02:57 +00:00
|
|
|
echo "QuickSync is downloading (but has completed once), stopping upload, limited download"
|
2019-08-20 04:39:10 +00:00
|
|
|
transmission-remote -u 0
|
2019-08-21 02:02:57 +00:00
|
|
|
transmission-remote -d $BACKGROUND_DL_RATE
|
2019-07-13 23:56:42 +00:00
|
|
|
elif [ -f $QUICKSYNC_BANDWIDTH_FILE ]; then
|
2019-06-15 23:02:44 +00:00
|
|
|
RATE=$(cat $QUICKSYNC_BANDWIDTH_FILE)
|
|
|
|
echo "Setting upload rate to $RATE kbps"
|
|
|
|
transmission-remote -u $RATE
|
2019-08-21 02:02:57 +00:00
|
|
|
transmission-remote -d $BACKGROUND_DL_RATE
|
2019-06-15 23:02:44 +00:00
|
|
|
else
|
|
|
|
echo "Setting upload rate to unlimited"
|
|
|
|
transmission-remote -U
|
2019-08-21 02:02:57 +00:00
|
|
|
transmission-remote -D
|
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
|