2014-02-18 13:33:40 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
# Copyright (C) 2014 OpenWrt.org
|
|
|
|
|
|
|
|
START=10
|
|
|
|
USE_PROCD=1
|
|
|
|
|
2021-04-10 00:22:48 +00:00
|
|
|
validate_system_section() {
|
2019-01-12 18:14:22 +00:00
|
|
|
uci_load_validate system system "$1" "$2" \
|
2017-11-07 08:45:50 +00:00
|
|
|
'hostname:string:OpenWrt' \
|
2014-02-18 13:33:40 +00:00
|
|
|
'conloglevel:uinteger' \
|
|
|
|
'buffersize:uinteger' \
|
|
|
|
'timezone:string:UTC' \
|
|
|
|
'zonename:string'
|
|
|
|
}
|
|
|
|
|
|
|
|
system_config() {
|
2019-01-12 18:14:22 +00:00
|
|
|
[ "$2" = 0 ] || {
|
2014-02-18 13:33:40 +00:00
|
|
|
echo "validation failed"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "$hostname" > /proc/sys/kernel/hostname
|
|
|
|
[ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
|
2021-06-24 17:42:53 +00:00
|
|
|
echo "$timezone" > /tmp/TZ
|
|
|
|
[ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/${zonename// /_}" ] \
|
|
|
|
&& ln -sf "/usr/share/zoneinfo/${zonename// /_}" /tmp/localtime \
|
|
|
|
&& rm -f /tmp/TZ
|
2014-02-18 13:33:40 +00:00
|
|
|
|
|
|
|
# apply timezone to kernel
|
base-files: use hwclock --systz
The date -k patch is non standard and will be removed in the next
commit.
Tested behavior to be identical with a simple C program:
#define _GNU_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/syscall.h>
int main()
{
struct timezone tt;
struct timezone tz;
int a = syscall(SYS_gettimeofday, NULL, &tt);
int b = gettimeofday(NULL, &tz);
printf("%d - %d, %d\n", a, tt.tz_minuteswest, tt.tz_dsttime);
printf("%d - %d, %d\n", b, tz.tz_minuteswest, tz.tz_dsttime);
}
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-02-01 00:15:52 +00:00
|
|
|
hwclock -u --systz
|
2014-02-18 13:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reload_service() {
|
|
|
|
config_load system
|
2019-01-12 18:14:22 +00:00
|
|
|
config_foreach validate_system_section system system_config
|
2014-02-18 13:33:40 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 00:22:48 +00:00
|
|
|
service_triggers() {
|
2014-02-18 13:33:40 +00:00
|
|
|
procd_add_reload_trigger "system"
|
|
|
|
procd_add_validation validate_system_section
|
|
|
|
}
|
|
|
|
|
|
|
|
start_service() {
|
|
|
|
reload_service
|
|
|
|
}
|