Skip to content

Commit

Permalink
make looping dependant on REFLECTOR_INTERVAL being defined
Browse files Browse the repository at this point in the history
  • Loading branch information
tmacro committed Nov 1, 2023
1 parent d95615f commit 4bfa8bf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions images/reflector/refresh-mirrors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit 4bfa8bf

Please sign in to comment.