Improve uploader toggle

This commit is contained in:
Taylor Helsper 2020-03-14 16:01:21 -05:00
parent d7d35d9804
commit 2f5846ae2a
3 changed files with 13 additions and 5 deletions

View File

@ -18,6 +18,11 @@ cp -f /usr/share/quicksync/settings.json $QUICKSYNC_CONFIG_DIR/settings.json
# Wait a bit for boot to complete
sleep 15s
# If marked as uploader, make sure QuickSync is enabled
if [ -f $UPLOADER_FILE ]; then
rm /mnt/hdd/mynode/settings/quicksync_disabled || true
fi
# Check if quicksync was disabled
while [ -f /mnt/hdd/mynode/settings/quicksync_disabled ]; do
# Pretend quicksync step is complete

View File

@ -2,11 +2,16 @@
source /usr/share/mynode/mynode_config.sh
sleep 1m
echo "Waiting until QuickSync is complete..."
while [ ! -f "$QUICKSYNC_COMPLETE_FILE" ]; do
sleep 1h
done
# No need to check for new torrent right away
sleep 2m
while true; do
# Wait a while... we don't want everyone starting on a new torrent at once
if [ -f $UPLOADER_FILE ]; then
@ -24,7 +29,8 @@ while true; do
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
sleep 30s
reboot
else
echo "Torrent has not changed."
fi

View File

@ -243,13 +243,10 @@ def get_journalctl_log(service_name):
# Uploader Functions
#==================================
def is_uploader():
return os.path.isfile("/home/bitcoin/.mynode/uploader") or \
os.path.isfile("/mnt/hdd/mynode/settings/uploader")
return os.path.isfile("/mnt/hdd/mynode/settings/uploader")
def set_uploader():
os.system("touch /home/bitcoin/.mynode/uploader")
os.system("touch /mnt/hdd/mynode/settings/uploader")
def unset_uploader():
os.system("rm -rf /home/bitcoin/.mynode/uploader")
os.system("rm -rf /mnt/hdd/mynode/settings/uploader")