[main]
@type = oneshot
@version = @vers@
@description = "Set localtime"
@options = ( !log )
@depends = ( mount-rw )
@user = ( root )

[start]
@execute =
(
	if { 66-yeller -cdp local-time -1 /dev/console starts... }

	# 1. Load envfile; if TZ is not empty, link appropriate zoneinfo file to
	#    /etc/localtime
	#
	# 2. If /etc/localtime is already set, do nothing; otherwise, if
	#    /etc/localtime is not a symbolic link, link zoneinfo file defined
	#    by def_tz, which is "GMT" by default
	#
	if -nt {

		execl-envfile ${conf_file}
		importas -D "" TZ TZ
		ifelse { [ -n "${TZ}" ] }
		{
			s6-ln -nsf /usr/share/zoneinfo/${TZ} /etc/localtime
		}
		if -t { [ ! -L /etc/localtime ] }
		s6-ln -nsf /usr/share/zoneinfo/${def_tz} /etc/localtime

	}
	66-yeller -fcdp local-time -1 /dev/console crashed!
)

[environment]
conf_file=!@bootconf@
def_tz=!GMT
