mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
d50eeea114
1. Split the oversized `cmd/agent` entrypoint into a multi-file package and update dev/build scripts to use the package path instead of compiling `main.go` directly. 2. Add a new `memoh` terminal UI for local bot chat, with Bubble Tea
38 lines
1021 B
Go
38 lines
1021 B
Go
package containerd
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
// TimezoneSpec returns environment variables that propagate the host timezone
|
|
// into the container without relying on file bind mounts like /etc/localtime.
|
|
// File mounts can fail for workspace containers when the target path is absent
|
|
// in the unpacked rootfs, while TZ is sufficient for Go, Node, and most tools.
|
|
func TimezoneSpec() ([]MountSpec, []string) {
|
|
var env []string
|
|
if tz := detectTimezone(); tz != "" {
|
|
env = append(env, "TZ="+tz)
|
|
}
|
|
return nil, env
|
|
}
|
|
|
|
func detectTimezone() string {
|
|
if tz := strings.TrimSpace(os.Getenv("TZ")); tz != "" {
|
|
return tz
|
|
}
|
|
if data, err := os.ReadFile("/etc/timezone"); err == nil {
|
|
if tz := strings.TrimSpace(string(data)); tz != "" {
|
|
return tz
|
|
}
|
|
}
|
|
if target, err := filepath.EvalSymlinks("/etc/localtime"); err == nil {
|
|
const zoneinfoPrefix = "/usr/share/zoneinfo/"
|
|
if strings.HasPrefix(target, zoneinfoPrefix) {
|
|
return strings.TrimPrefix(target, zoneinfoPrefix)
|
|
}
|
|
}
|
|
return ""
|
|
}
|