Enhanced system timezone configuration via U-Boot. (#974)

pull/987/head
gtxaspec 2023-09-07 01:01:00 -07:00 committed by GitHub
parent 48b3c4b8c3
commit 4fc61f2a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
# Setting the TimeZone for all processes # Setting the TimeZone for all processes
/usr/sbin/timezone.sh
export TZ=$(cat /etc/TZ) export TZ=$(cat /etc/TZ)
# Set the firmware creation time as the base system time # Set the firmware creation time as the base system time

View File

@ -0,0 +1,41 @@
#!/bin/sh
# Get the timezone from the u-boot environment variable
timezone=$(fw_printenv -n timezone 2>/dev/null)
if [ -z "$timezone" ]; then
echo "Timezone env variable not found, using system default."
exit 1
fi
echo "User defined timezone: $timezone"
# Check if the values in /etc/timezone and /etc/TZ match the ones from fw_printenv
current_timezone=$(cat /etc/timezone 2>/dev/null)
current_tz_value=$(cat /etc/TZ 2>/dev/null)
if [ "$timezone" = "$current_timezone" ] && [ "$timezone" = "$current_tz_value" ]; then
echo "Timezone settings are already up to date."
exit 0
fi
# Search for the timezone in the file
matching_line=$(zcat /var/www/a/tz.js.gz | grep -i -F "$timezone")
if [ -z "$matching_line" ]; then
echo "Timezone not found in system file."
exit 1
fi
# Extract the value associated with the timezone
value=$(echo "$matching_line" | awk -F',' '{print $2}' | awk -F':' '{print $2}' | tr -d "'}")
# Write the TZ file first
echo $value > /etc/TZ
# Then write the timezone file
echo $timezone > /etc/timezone
export TZ=$value
if tty -s; then
echo "timezone.sh: You are running from a shell, please restart or log out to update timezone environment variables."
fi