From 4bfa8bfcf9a25b8556a1e0b332e84d67e39ce0a0 Mon Sep 17 00:00:00 2001 From: Taylor McKinnon Date: Wed, 1 Nov 2023 12:46:17 -0700 Subject: [PATCH] make looping dependant on REFLECTOR_INTERVAL being defined --- images/reflector/refresh-mirrors.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/images/reflector/refresh-mirrors.sh b/images/reflector/refresh-mirrors.sh index 2d6e645..832055d 100755 --- a/images/reflector/refresh-mirrors.sh +++ b/images/reflector/refresh-mirrors.sh @@ -4,10 +4,6 @@ set -e -if [ -z "$REFLECTOR_INTERVAL" ]; then - INTERVAL="6h" -fi - if [ -z "$REFLECTOR_ARGS" ]; then REFLECTOR_ARGS="-c US --sort rate -l 10 -p https" fi @@ -16,6 +12,8 @@ if [ -z "$REFLECTOR_FILE" ]; then REFLECTOR_FILE="/opt/reflector/mirrorlist" fi +REFLECTOR_ARGS="$REFLECTOR_ARGS --save $REFLECTOR_FILE" + if [ ! -d "$(dirname $REFLECTOR_FILE)" ]; then mkdir -p "$(dirname $REFLECTOR_FILE)" fi @@ -24,9 +22,14 @@ if [ ! -f "$REFLECTOR_FILE" ]; then touch "$REFLECTOR_FILE" fi +if [ -z "$REFLECTOR_INTERVAL" ]; then + reflector $REFLECTOR_ARGS + exit 0 +fi + while true; do echo "[$(date -Iseconds)] Refreshing mirrorlist..." - reflector $REFLECTOR_ARGS > $REFLECTOR_FILE + reflector $REFLECTOR_ARGS echo "[$(date -Iseconds)] Sleeping for $INTERVAL..." sleep $INTERVAL done