Add $OSUBOOT_MAX_CACHE_TIME config variable

This commit is contained in:
JeremyStar™ 2024-08-09 23:40:08 +02:00
parent 615a0f781e
commit 9c14e94090
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -17,6 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# Process environment variables # Process environment variables
# COLORLESS
if [ -z "${OSUBOOT_COLORLESS}" ]; then if [ -z "${OSUBOOT_COLORLESS}" ]; then
COLOR_SPECIAL="\e[0;35m" COLOR_SPECIAL="\e[0;35m"
COLOR_DEFAULT="\e[0;37m" COLOR_DEFAULT="\e[0;37m"
@ -25,6 +26,16 @@ if [ -z "${OSUBOOT_COLORLESS}" ]; then
COLOR_OTHER="\e[0;33m" COLOR_OTHER="\e[0;33m"
RESET="\e[0m" RESET="\e[0m"
fi 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 # Display startup messages
echo -en "${COLOR_SPECIAL}" echo -en "${COLOR_SPECIAL}"
@ -87,7 +98,7 @@ fi
# Download osu!lazer # Download osu!lazer
echo -en "${COLOR_DEFAULT}:: Downloading osu!lazer" echo -en "${COLOR_DEFAULT}:: Downloading osu!lazer"
if [ -z "${OSUBOOT_DRYRUN}" ]; then 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}" echo -e "${RESET}"
wget --quiet --show-progress -O "$HOME/.cache/osu.AppImage.tmp" "https://github.com/ppy/osu/releases/latest/download/osu.AppImage" 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" mv "${HOME}/.cache/osu.AppImage.tmp" "${HOME}/.cache/osu.AppImage"