Skip to content

Commit 36b4f30

Browse files
committed
Improved system time config
1 parent 497d340 commit 36b4f30

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/configure-system-time.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22
source 'scripts/common/filesystem.sh'
3+
source "${REPO_SCRIPTS_COMMON_DIR}/common.sh"
4+
5+
PREFERRED_TIMEZONE='Europe/Bucharest'
36

47
LOCALE_CONF_FILE_PATH="${ROOT_ETC}/locale.conf"
58
LOCALTIME_FILE_PATH="${ROOT_ETC}/localtime"
@@ -9,9 +12,12 @@ echo 'Setting up the time locale...'
912
echo 'LC_TIME=ro_RO.UTF-8'
1013
} > "${LOCALE_CONF_FILE_PATH}"
1114

12-
if [ ! -f "${LOCALTIME_FILE_PATH}" ]; then
15+
if does_bin_exist 'timedatectl'; then
16+
run_as_su timedatectl set-timezone "${PREFERRED_TIMEZONE}"
17+
elif [ ! -f "${LOCALTIME_FILE_PATH}" ]; then
1318
echo 'Setting up the local time...'
1419

15-
ln -sf '/usr/share/zoneinfo/Europe/Bucharest' "${LOCALTIME_FILE_PATH}"
16-
does_bin_exist 'hwclock' && hwclock --systohc
20+
ln -sf "${ROOT_USER_SHARE}/zoneinfo/${PREFERRED_TIMEZONE}" "${LOCALTIME_FILE_PATH}"
1721
fi
22+
23+
does_bin_exist 'hwclock' && hwclock --systohc

0 commit comments

Comments
 (0)