Skip to content

Commit 1831bc9

Browse files
authored
feat: Configure timezone with /boot/timezone cfg file (#83)
The system time is now set to UTC. The user timezone can be set with /boot/timezone containing a single line with the TZ name. This resolves #78
1 parent 2a27ead commit 1831bc9

File tree

11 files changed

+59
-7
lines changed

11 files changed

+59
-7
lines changed

buildroot-external/board/raspberrypi/boot-overlay/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ Attention:
2323
- If a wpa_supplicant.conf file is present in /boot, the initial setup is skipped during first run.
2424
- The Raspberry Pi 0 W doesn't support 5GHz networks!
2525

26+
### Timezone configuration
27+
28+
The system time is automatically set with NTP and the default timezone is UTC.
29+
30+
- To set another timezone create a file named `timezone` in the root of this boot partition.
31+
- Content is a single line containing the Linux TZ name.
32+
See <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> for a list of valid TZ database names.
33+
Examples:
34+
- Europe/Copenhagen
35+
- Asia/Hong_Kong
36+
- America/Vancouver
37+
2638
### Bluetooth Serial Console
2739

2840
To enable a Bluetooth serial console, create a marker file `btconsole` in the root of this boot partition.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Europe/Zurich

buildroot-external/rootfs-overlay/etc/profile.d/yio.sh buildroot-external/board/raspberrypi/rootfs-overlay/etc/profile.d/yio.sh

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export YIO_OS_VERSION=$BUILD_VERSION
1212
export YIO_OS_GITHASH=$GIT_HASH
1313
export YIO_LOG_DIR=/var/log
1414
export YIO_LOG_DIR_UPDATE=/boot/log
15+
export YIO_CFG_OVERRIDE_DIR=/boot

buildroot-external/board/remote/boot-overlay/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ Attention:
2222
- If a wpa_supplicant.conf file is present in /boot, the initial setup is skipped during first run.
2323
- The Raspberry Pi 0 W doesn't support 5GHz networks!
2424

25+
### Timezone configuration
26+
27+
The system time is automatically set with NTP and the default timezone is UTC.
28+
29+
- To set another timezone create a file named `timezone` in the root of this boot partition.
30+
- Content is a single line containing the Linux TZ name.
31+
See <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> for a list of valid TZ database names.
32+
Examples:
33+
- Europe/Copenhagen
34+
- Asia/Hong_Kong
35+
- America/Vancouver
36+
2537
### Bluetooth Serial Console
2638

2739
To enable a Bluetooth serial console, create a marker file `btconsole` in the root of this boot partition.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Europe/Zurich
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# home directory is not freely changeable!
2+
# systemd services don't support env variables in ExecStart!
3+
export YIO_HOME=/opt/yio
4+
export YIO_APP_DIR=${YIO_HOME}/app
5+
export YIO_PLUGIN_DIR=${YIO_HOME}/app-plugins
6+
export YIO_MEDIA_DIR=${YIO_HOME}/media
7+
export YIO_SCRIPT_DIR=${YIO_HOME}/scripts
8+
export YIO_WEB_CONFIGURATOR_DIR=${YIO_HOME}/web-configurator
9+
# remote-os release, set during build
10+
export YIO_OS_VERSION=$BUILD_VERSION
11+
# Git hash of the remote-os repo, set during build
12+
export YIO_OS_GITHASH=$GIT_HASH
13+
export YIO_LOG_DIR=/var/log
14+
export YIO_LOG_DIR_UPDATE=/boot/log
15+
export YIO_CFG_OVERRIDE_DIR=/boot

buildroot-external/configs/remote_defconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ BR2_TARGET_GENERIC_ISSUE="Welcome to YIO Remote"
1515
BR2_INIT_SYSTEMD=y
1616
BR2_TARGET_GENERIC_ROOT_PASSWD="yioremote"
1717
BR2_GENERATE_LOCALE="en_US.UTF-8"
18-
BR2_TARGET_LOCALTIME="Europe/Copenhagen"
18+
BR2_TARGET_LOCALTIME="UTC"
1919
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_YIOS_PATH)/rootfs-overlay $(BR2_EXTERNAL_YIOS_PATH)/board/remote/rootfs-overlay"
2020
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_YIOS_PATH)/scripts/post-build.sh"
2121
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_YIOS_PATH)/scripts/post-image.sh"

buildroot-external/configs/rpi0w_defconfig

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ BR2_TARGET_GENERIC_HOSTNAME="yio-dev"
1717
BR2_TARGET_GENERIC_ISSUE="Welcome to YIO Developer Edition"
1818
BR2_INIT_SYSTEMD=y
1919
BR2_TARGET_GENERIC_ROOT_PASSWD="yioremote"
20+
BR2_GENERATE_LOCALE="en_US.UTF-8"
21+
BR2_TARGET_LOCALTIME="UTC"
2022
BR2_TARGET_GENERIC_GETTY_PORT="tty1"
2123
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_YIOS_PATH)/rootfs-overlay $(BR2_EXTERNAL_YIOS_PATH)/board/raspberrypi/rootfs-overlay"
2224
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_YIOS_PATH)/scripts/post-build.sh"

buildroot-external/configs/rpi3_defconfig

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ BR2_TARGET_GENERIC_HOSTNAME="yio-dev"
1818
BR2_TARGET_GENERIC_ISSUE="Welcome to YIO Developer Edition"
1919
BR2_INIT_SYSTEMD=y
2020
BR2_TARGET_GENERIC_ROOT_PASSWD="yioremote"
21+
BR2_GENERATE_LOCALE="en_US.UTF-8"
22+
BR2_TARGET_LOCALTIME="UTC"
2123
BR2_TARGET_GENERIC_GETTY_PORT="tty1"
2224
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_YIOS_PATH)/rootfs-overlay $(BR2_EXTERNAL_YIOS_PATH)/board/raspberrypi/rootfs-overlay"
2325
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_YIOS_PATH)/scripts/post-build.sh"

buildroot-external/rootfs-overlay/opt/yio/app-launch.sh

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
. /etc/profile.d/yio.sh
55
. /etc/profile.d/qt.sh
66

7+
if [[ -f ${YIO_CFG_OVERRIDE_DIR}/timezone ]]; then
8+
export TZ="$(cat ${YIO_CFG_OVERRIDE_DIR}/timezone)"
9+
else
10+
export TZ="$(cat /etc/timezone)"
11+
fi
12+
713
${YIO_SCRIPT_DIR}/wifi-copy-config.sh
814

915
${YIO_SCRIPT_DIR}/firstrun.sh
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#!/bin/bash
22

3-
if [ -e /boot/wpa_supplicant.conf ]
3+
if [ -e ${YIO_CFG_OVERRIDE_DIR}/wpa_supplicant.conf ]
44
then
5-
if cmp -s /boot/wpa_supplicant.conf /var/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
5+
if cmp -s ${YIO_CFG_OVERRIDE_DIR}/wpa_supplicant.conf /var/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
66
then
7-
echo "wpa_supplicant.conf in /boot already copied"
7+
echo "wpa_supplicant.conf in ${YIO_CFG_OVERRIDE_DIR} already copied"
88
else
9-
echo "Using provided wpa_supplicant.conf in /boot"
9+
echo "Using provided wpa_supplicant.conf in ${YIO_CFG_OVERRIDE_DIR}"
1010

1111
# stop wifi
1212
systemctl stop wpa_supplicant@wlan0.service
1313
# copy config file
14-
cp /boot/wpa_supplicant.conf /var/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
14+
cp ${YIO_CFG_OVERRIDE_DIR}/wpa_supplicant.conf /var/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
1515
# restart wifi
1616
systemctl start wpa_supplicant@wlan0.service
1717
sleep 3
1818

1919
touch /var/yio/wificopy
2020
fi
2121
else
22-
echo "No wpa_supplicant.conf in /boot"
22+
echo "No wpa_supplicant.conf in ${YIO_CFG_OVERRIDE_DIR}"
2323
rm -f /var/yio/wificopy
2424
fi

0 commit comments

Comments
 (0)