diff --git a/internal/service/home.go b/internal/service/home.go index 6a3286f9..6478e094 100644 --- a/internal/service/home.go +++ b/internal/service/home.go @@ -20,6 +20,7 @@ import ( "github.com/acepanel/panel/pkg/api" "github.com/acepanel/panel/pkg/config" "github.com/acepanel/panel/pkg/db" + "github.com/acepanel/panel/pkg/os" "github.com/acepanel/panel/pkg/shell" "github.com/acepanel/panel/pkg/tools" "github.com/acepanel/panel/pkg/types" @@ -115,6 +116,33 @@ func (s *HomeService) SystemInfo(w http.ResponseWriter, r *http.Request) { }) } + // 系统是否支持 + osSupported := true + if os.IsRHEL() { + minVer := version.Must(version.NewVersion("9.0")) + currentVerStr := strings.Split(hostInfo.PlatformVersion, " ")[0] + currentVer, err := version.NewVersion(currentVerStr) + if err != nil || currentVer.LessThan(minVer) { + osSupported = false + } + } + if os.IsDebian() { + minVer := version.Must(version.NewVersion("12.0")) + currentVerStr := strings.Split(hostInfo.PlatformVersion, " ")[0] + currentVer, err := version.NewVersion(currentVerStr) + if err != nil || currentVer.LessThan(minVer) { + osSupported = false + } + } + if os.IsUbuntu() { + minVer := version.Must(version.NewVersion("22.04")) + currentVerStr := strings.Split(hostInfo.PlatformVersion, " ")[0] + currentVer, err := version.NewVersion(currentVerStr) + if err != nil || currentVer.LessThan(minVer) { + osSupported = false + } + } + Success(w, chix.M{ "procs": hostInfo.Procs, "hostname": hostInfo.Hostname, @@ -128,6 +156,8 @@ func (s *HomeService) SystemInfo(w http.ResponseWriter, r *http.Request) { "kernel_arch": hostInfo.KernelArch, "kernel_version": hostInfo.KernelVersion, "os_name": hostInfo.Platform + " " + hostInfo.PlatformVersion, + "os_supported": osSupported, + "os_eol": os.IsEOL(), "boot_time": hostInfo.BootTime, "uptime": hostInfo.Uptime, "nets": nets, diff --git a/pkg/os/os.go b/pkg/os/os.go index 3a407605..f59a988c 100644 --- a/pkg/os/os.go +++ b/pkg/os/os.go @@ -6,6 +6,7 @@ import ( "net" "os" "strings" + "time" ) func readOSRelease() map[string]string { @@ -62,6 +63,59 @@ func IsUbuntu() bool { return id == "ubuntu" || strings.Contains(idLike, "ubuntu") } +// IsEOL 判断系统是否已到达生命周期终点 +func IsEOL() bool { + eolTimeTable := map[string]map[string]time.Time{ + "rhel": { + "9": time.Date(2032, 5, 31, 0, 0, 0, 0, time.UTC), + "10": time.Date(2035, 5, 31, 0, 0, 0, 0, time.UTC), + }, + "debian": { + "12": time.Date(2028, 6, 30, 0, 0, 0, 0, time.UTC), + "13": time.Date(2030, 6, 30, 0, 0, 0, 0, time.UTC), + }, + "ubuntu": { + "22.04": time.Date(2027, 4, 1, 0, 0, 0, 0, time.UTC), + "24.04": time.Date(2029, 5, 31, 0, 0, 0, 0, time.UTC), + }, + } + + osRelease := readOSRelease() + + if IsRHEL() { + version, ok := osRelease["VERSION_ID"] + if !ok { + return false + } + majorVersion := strings.Split(version, ".")[0] + if eol, ok := eolTimeTable["rhel"][majorVersion]; ok { + return time.Now().After(eol) + } + } + if IsUbuntu() { + version, ok := osRelease["VERSION_ID"] + if !ok { + return false + } + majorVersion := strings.Join(strings.Split(version, ".")[:2], ".") + if eol, ok := eolTimeTable["ubuntu"][majorVersion]; ok { + return time.Now().After(eol) + } + } + if IsDebian() { + version, ok := osRelease["VERSION_ID"] + if !ok { + return false + } + majorVersion := strings.Split(version, ".")[0] + if eol, ok := eolTimeTable["debian"][majorVersion]; ok { + return time.Now().After(eol) + } + } + + return false +} + func TCPPortInUse(port uint) bool { addr := fmt.Sprintf(":%d", port) conn, err := net.Listen("tcp", addr) diff --git a/web/src/views/home/IndexView.vue b/web/src/views/home/IndexView.vue index 3f55a4c7..543bf253 100644 --- a/web/src/views/home/IndexView.vue +++ b/web/src/views/home/IndexView.vue @@ -54,7 +54,9 @@ const { data: systemInfo } = useRequest(home.systemInfo, { go_version: '', kernel_arch: '', kernel_version: '', + os_eol: false, os_name: '', + os_supported: true, boot_time: 0, uptime: 0, nets: [], @@ -417,6 +419,28 @@ if (import.meta.hot) {
+ + + {{ + $gettext( + 'Your operating system %{ os_name } has reached its end-of-life. Please consider upgrading to a supported version to ensure optimal performance and security.', + { + os_name: systemInfo?.os_name + } + ) + }} + + + + {{ + $gettext( + 'Your operating system %{ os_name } is not officially supported. Some features may not work as expected. Please consider using a supported operating system for the best experience.', + { + os_name: systemInfo?.os_name + } + ) + }} +