diff --git a/initrd/bin/change-time b/initrd/bin/change-time index 890b3c5d..f3568407 100755 --- a/initrd/bin/change-time +++ b/initrd/bin/change-time @@ -8,11 +8,10 @@ echo -e -n "You need to set the time according to the UTC/GMT timezone please ch get_date () { - local field_name min max digits + local field_name min max field_name="$1" min="$2" max="$3" - digits="$4" echo "Please insert $field_name (between $min-$max)" read -r value echo @@ -25,21 +24,21 @@ get_date () { echo done - # Pad with zeroes to digits - value="$(printf "%0${digits}u" "$value")" + # Pad with zeroes to length of maximum value + value="$(printf "%0${#max}u" "$value")" } -get_date "year" "2024" "2200" "4" +get_date "year" "2024" "2200" year=$value -get_date "month" "01" "12" "2" +get_date "month" "01" "12" month=$value -get_date "day" "01" "31" "2" +get_date "day" "01" "31" day=$value -get_date "hour" "00" "23" "2" +get_date "hour" "00" "23" hour=$value -get_date "minute" "00" "59" "2" +get_date "minute" "00" "59" min=$value -get_date "second" "00" "59" "2" +get_date "second" "00" "59" sec=$value if ! date -s "$year-$month-$day $hour:$min:$sec" &>/dev/null; then