mynode/rootfs/standard/usr/bin/mynode_bandwidth.sh

60 lines
1.6 KiB
Bash
Raw Normal View History

2019-06-15 23:02:44 +00:00
#!/bin/bash
set -e
set -x
source /usr/share/mynode/mynode_config.sh
# Let transmission startup
sleep 60s
2019-07-25 02:51:12 +00:00
# If marked as uploader, dont slow down
while [ -f $UPLOADER_FILE ]; do
echo "Marked as uploader, unlimited upload"
transmission-remote -U
sleep 1h
done
2019-06-15 23:02:44 +00:00
# Upload slowly while downloading
transmission-remote -u 0
# Wait until download is complete...
while [ ! -f "/mnt/hdd/mynode/quicksync/.quicksync_complete" ]; do
sleep 30s
done
# Wait until blockchain is synced...
while [ ! -f "/mnt/hdd/mynode/.mynode_bitcoind_synced" ]; do
sleep 30s
done
# Enable uploading
echo "QuickSync Complete! Enabling Uploading."
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
echo "Marked as uploader, unlimited upload"
transmission-remote -U
elif [ ! -f "/mnt/hdd/mynode/quicksync/.quicksync_complete" ]; then
echo "QuickSync not complete, stopping upload"
transmission-remote -u 0
elif [ ! -f "/mnt/hdd/mynode/.mynode_bitcoind_synced" ]; then
echo "Bitcoin not synced, stopping upload"
transmission-remote -u 0
2019-08-20 04:39:10 +00:00
elif [[ "$PERCENT" != *"100"* ]]; then
echo "QuickSync is downloading, stopping upload"
transmission-remote -u 0
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
else
echo "Setting upload rate to unlimited"
transmission-remote -U
fi
sleep 1h
2019-06-15 23:02:44 +00:00
done
# We should not exit
exit 1