From 6035ec19514046f219981a56f9b09c91d79781df Mon Sep 17 00:00:00 2001 From: simonzhangsz Date: Wed, 17 Apr 2024 15:35:25 +0800 Subject: [PATCH] fix: failed upload license at first time --- features/cm/license.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/features/cm/license.go b/features/cm/license.go index 07510371..94857ec0 100644 --- a/features/cm/license.go +++ b/features/cm/license.go @@ -7,7 +7,6 @@ import ( "os" "os/exec" "strings" - "time" "be.ems/lib/dborm" "be.ems/lib/log" @@ -154,21 +153,21 @@ func DeleteLcenseFile(w http.ResponseWriter, r *http.Request) { services.ResponseStatusOK204NoContent(w) } -type MMLRequest struct { - MML []string `json:"mml"` -} +// type MMLRequest struct { +// MML []string `json:"mml"` +// } -var TIME_DELAY_AFTER_WRITE time.Duration = 200 -var TIME_DEAD_LINE time.Duration = 10 +// var TIME_DELAY_AFTER_WRITE time.Duration = 200 +// var TIME_DEAD_LINE time.Duration = 10 -func init() { - if config.GetYamlConfig().MML.Sleep != 0 { - TIME_DELAY_AFTER_WRITE = time.Duration(config.GetYamlConfig().MML.Sleep) - } - if config.GetYamlConfig().MML.DeadLine != 0 { - TIME_DEAD_LINE = time.Duration(config.GetYamlConfig().MML.DeadLine) - } -} +// func init() { +// if config.GetYamlConfig().MML.Sleep != 0 { +// TIME_DELAY_AFTER_WRITE = time.Duration(config.GetYamlConfig().MML.Sleep) +// } +// if config.GetYamlConfig().MML.DeadLine != 0 { +// TIME_DEAD_LINE = time.Duration(config.GetYamlConfig().MML.DeadLine) +// } +// } func UploadLicenseFileData(w http.ResponseWriter, r *http.Request) { log.Info("UploadLicenseFileData processing... ") @@ -274,7 +273,8 @@ func UploadLicenseFileData(w http.ResponseWriter, r *http.Request) { } // backup system.ini to system.ini.bak sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip) - cpCmd := fmt.Sprintf("sudo cp -f %s/system.ini %s/system.ini.bak", neLicensePath, neLicensePath) + cpCmd := fmt.Sprintf("sudo test -f %s/system.ini && cp -f %s/system.ini %s/system.ini.bak", + neLicensePath, neLicensePath, neLicensePath) cmd = exec.Command("ssh", sshHost, cpCmd) out, err = cmd.CombinedOutput() log.Debugf("Exec output: %v", string(out))