From 9c14e9409045bfb43aede92ee8c4ead090947424 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Fri, 9 Aug 2024 23:40:08 +0200 Subject: [PATCH] Add $OSUBOOT_MAX_CACHE_TIME config variable --- osuboot.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/osuboot.sh b/osuboot.sh index 9d7a5f6..922d8b5 100755 --- a/osuboot.sh +++ b/osuboot.sh @@ -17,6 +17,7 @@ # along with this program. If not, see . # Process environment variables +# COLORLESS if [ -z "${OSUBOOT_COLORLESS}" ]; then COLOR_SPECIAL="\e[0;35m" COLOR_DEFAULT="\e[0;37m" @@ -25,6 +26,16 @@ if [ -z "${OSUBOOT_COLORLESS}" ]; then COLOR_OTHER="\e[0;33m" RESET="\e[0m" fi +# MAX_CACHE_TIME +if [ -z "${OSUBOOT_MAX_CACHE_TIME}" ]; then + OSUBOOT_MAX_CACHE_TIME=1 +elif [[ ! ${OSUBOOT_MAX_CACHE_TIME} == ?(-)+([0-9]) ]]; then + echo "Initialization error: \$OSUBOOT_MAX_CACHE_TIME is not a valid integer" + exit 1 +elif [ "${OSUBOOT_MAX_CACHE_TIME}" -lt "1" ]; then + echo "Initialization error: \$OSUBOOT_MAX_CACHE_TIME must be at least 1" + exit 1 +fi # Display startup messages echo -en "${COLOR_SPECIAL}" @@ -87,7 +98,7 @@ fi # Download osu!lazer echo -en "${COLOR_DEFAULT}:: Downloading osu!lazer" if [ -z "${OSUBOOT_DRYRUN}" ]; then - if [ ! -f "$HOME/.cache/osu.AppImage" ] || [ -n "$(find "$HOME/.cache/osu.AppImage" -ctime +1 2>/dev/null)" ]; then + if [ ! -f "$HOME/.cache/osu.AppImage" ] || [ -n "$(find "$HOME/.cache/osu.AppImage" -ctime "+${OSUBOOT_MAX_INITIALIZATION_TIME}" 2>/dev/null)" ]; then echo -e "${RESET}" wget --quiet --show-progress -O "$HOME/.cache/osu.AppImage.tmp" "https://github.com/ppy/osu/releases/latest/download/osu.AppImage" mv "${HOME}/.cache/osu.AppImage.tmp" "${HOME}/.cache/osu.AppImage"