Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions timezone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@
# You can download the latest version of this script from:
# https://github.com/MiSTer-devel/Scripts_MiSTer

# version 1.3 - 2020-06-18 - use a query to get the timezone, plus some cleaning
# Version 1.2 - 2019-03-02 - Changed "/media/fat/timezone" to "/media/fat/linux/timezone", removed -k option from curl.
# Version 1.1 - 2019-01-08 - Changed "http://ip-api.com/json/" to "http://www.ip-api.com/json/".
# Version 1.0 - 2019-01-08 - First commit.

TIMEZONE="$(curl -sLf "http://www.ip-api.com/json/" | grep -o "\"timezone\" *: *\"[^\"]*" | grep -o "[^\"]*$")"
if echo "$TIMEZONE" | grep -q "/"
then
cp "/usr/share/zoneinfo/posix/$TIMEZONE" "/media/fat/linux/timezone"
echo "Timezone set to"
echo "$TIMEZONE."
TIMEZONE="$(curl -sLf "http://www.ip-api.com/line?fields=timezone")"

if grep -q "/" <<< "${TIMEZONE}" ; then
cp "/usr/share/zoneinfo/posix/${TIMEZONE}" "/media/fat/linux/timezone"
echo "Timezone set to"
echo "${TIMEZONE}."
else
echo "Unable to get"
echo "your timezone."
echo "Unable to get"
echo "your timezone."
fi
exit 0

exit 0