| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 | package self_checkimport (	"github.com/0xJacky/Nginx-UI/internal/helper"	"github.com/0xJacky/Nginx-UI/internal/translation"	"github.com/elliotchance/orderedmap/v3"	"github.com/uozi-tech/cosy")type Task struct {	Key         string	Name        *translation.Container	Description *translation.Container	CheckFunc   func() error	FixFunc     func() error}type ReportStatus stringconst (	ReportStatusSuccess ReportStatus = "success"	ReportStatusWarning ReportStatus = "warning"	ReportStatusError   ReportStatus = "error")type Report struct {	Key         string                 `json:"key"`	Name        *translation.Container `json:"name"`	Description *translation.Container `json:"description,omitempty"`	Fixable     bool                   `json:"fixable"`	Err         *cosy.Error            `json:"err,omitempty"`	Status      ReportStatus           `json:"status"`}type Reports []*Reportvar selfCheckTasks = []*Task{	{		Key:  "Directory-Sites",		Name: translation.C("Sites directory exists"),		Description: translation.C("Check if the " +			"sites-available and sites-enabled directories are " +			"under the nginx configuration directory"),		CheckFunc: CheckSitesDirectory,		FixFunc:   FixSitesDirectory,	},	{		Key:  "Directory-Streams",		Name: translation.C("Streams directory exists"),		Description: translation.C("Check if the " +			"streams-available and streams-enabled directories are " +			"under the nginx configuration directory"),		CheckFunc: CheckStreamDirectory,		FixFunc:   FixStreamDirectory,	},	{		Key:  "NginxConf-Sites-Enabled",		Name: translation.C("Nginx.conf includes sites-enabled directory"),		Description: translation.C("Check if the nginx.conf includes the " +			"sites-enabled directory"),		CheckFunc: CheckNginxConfIncludeSites,		FixFunc:   FixNginxConfIncludeSites,	},	{		Key:  "NginxConf-Streams-Enabled",		Name: translation.C("Nginx.conf includes streams-enabled directory"),		Description: translation.C("Check if the nginx.conf includes the " +			"streams-enabled directory"),		CheckFunc: CheckNginxConfIncludeStreams,		FixFunc:   FixNginxConfIncludeStreams,	},	{		Key:  "NginxConf-ConfD",		Name: translation.C("Nginx.conf includes conf.d directory"),		Description: translation.C("Check if the nginx.conf includes the " +			"conf.d directory"),		CheckFunc: CheckNginxConfIncludeConfD,		FixFunc:   FixNginxConfIncludeConfD,	},	{		Key:         "NginxConf-Directory",		Name:        translation.C("Nginx configuration directory exists"),		Description: translation.C("Check if the nginx configuration directory exists"),		CheckFunc:   CheckConfigDir,	},	{		Key:         "NginxConf-Entry-File",		Name:        translation.C("Nginx configuration entry file exists"),		Description: translation.C("Check if the nginx configuration entry file exists"),		CheckFunc:   CheckConfigEntryFile,	},	{		Key:         "NginxPID-Path",		Name:        translation.C("Nginx PID path exists"),		Description: translation.C("Check if the nginx PID path exists"),		CheckFunc:   CheckPIDPath,	},	{		Key:         "NginxAccessLog-Path",		Name:        translation.C("Nginx access log path exists"),		Description: translation.C("Check if the nginx access log path exists"),		CheckFunc:   CheckAccessLogPath,	},	{		Key:         "NginxErrorLog-Path",		Name:        translation.C("Nginx error log path exists"),		Description: translation.C("Check if the nginx error log path exists"),		CheckFunc:   CheckErrorLogPath,	},}var selfCheckTaskMap = orderedmap.NewOrderedMap[string, *Task]()func init() {	for _, task := range selfCheckTasks {		selfCheckTaskMap.Set(task.Key, task)	}	if helper.InNginxUIOfficialDocker() {		selfCheckTasks = append(selfCheckTasks, &Task{			Name:        translation.C("Docker socket exists"),			Description: translation.C("Check if the docker socket exists."),			CheckFunc:   CheckDockerSocket,		})	}}
 |