MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / CheckSetup

Function CheckSetup

model/main.go:90–115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88}
89
90func CheckSetup() {
91 setup := GetSetup()
92 if setup == nil {
93 // No setup record exists, check if we have a root user
94 if RootUserExists() {
95 common.SysLog("system is not initialized, but root user exists")
96 // Create setup record
97 newSetup := Setup{
98 Version: common.Version,
99 InitializedAt: time.Now().Unix(),
100 }
101 err := DB.Create(&newSetup).Error
102 if err != nil {
103 common.SysLog("failed to create setup record: " + err.Error())
104 }
105 constant.Setup = true
106 } else {
107 common.SysLog("system is not initialized and no root user exists")
108 constant.Setup = false
109 }
110 } else {
111 // Setup record exists, system is initialized
112 common.SysLog("system is already initialized at: " + time.Unix(setup.InitializedAt, 0).String())
113 constant.Setup = true
114 }
115}
116
117func chooseDB(envName string, isLog bool) (*gorm.DB, error) {
118 defer func() {

Callers 1

InitResourcesFunction · 0.92

Calls 4

SysLogFunction · 0.92
RootUserExistsFunction · 0.85
ErrorMethod · 0.80
GetSetupFunction · 0.70

Tested by

no test coverage detected