From 2b364b93a7146b8c0007307cdd6bb2079c79ab7a Mon Sep 17 00:00:00 2001 From: Robert Wlodarczyk Date: Sun, 5 Mar 2023 12:02:18 -0800 Subject: [PATCH] fix: fixing @random since it was broken and removing @every since it never worked. --- entrypoint.sh | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 90a3f33..247943d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -118,8 +118,11 @@ make_cmd() { } parse_schedule() { - case $1 in - "@yearly"|"@annually") + IFS=" " + read -a params <<< "$@" + + case ${params[0]} in + "@yearly" | "@annually") echo "0 0 1 1 *" ;; "@monthly") @@ -137,36 +140,16 @@ parse_schedule() { "@hourly") echo "0 * * * *" ;; - "@every") - TIME=$2 - TOTAL=0 - - M=$(echo "${TIME}" | grep -o '[0-9]\+m') - H=$(echo "${TIME}" | grep -o '[0-9]\+h') - D=$(echo "${TIME}" | grep -o '[0-9]\+d') - - if [ -n "${M}" ]; then - TOTAL=$((TOTAL + ${M::-1})) - fi - if [ -n "${H}" ]; then - TOTAL=$((TOTAL + ${H::-1} * 60)) - fi - if [ -n "${D}" ]; then - TOTAL=$((TOTAL + ${D::-1} * 60 * 24)) - fi - - echo "*/${TOTAL} * * * *" - ;; "@random") - for when in "$@" + M="*" + H="*" + D="*" + + for when in "${params[@]:1}" do - if [ "$when" == "@random" ]; then - continue - fi - M H D="*" case $when in "@m") - M=$(shuf -i 0-6 -n 1) + M=$(shuf -i 0-59 -n 1) ;; "@h") H=$(shuf -i 0-23 -n 1) @@ -180,7 +163,7 @@ parse_schedule() { echo "${M} ${H} * * ${D}" ;; *) - echo "${@}" + echo "${params[@]}" ;; esac }