fix: 将restagent改为omc

This commit is contained in:
TsMask
2024-07-10 15:33:45 +08:00
parent f5a2d79346
commit 14bf73130c
14 changed files with 19 additions and 58 deletions

View File

@@ -16,7 +16,7 @@ fi
case "${extension}" in
deb)
if [ ${neType} == "OMC" ]; then
systemctl stop restagent.service
systemctl stop omc.service
fi
expect <<EOF > ${logFile}
spawn dpkg -i --force-all "$filename"
@@ -32,7 +32,7 @@ EOF
;;
rpm)
if [ ${neType} == "OMC" ]; then
systemctl stop restagent.service
systemctl stop omc.service
fi
expect <<EOF > ${logFile}
spawn rpm -Uvh "$filename"

View File

@@ -1,6 +1,6 @@
#!/bin/bash
process_name="restagent"
process_name="omc"
if ! pgrep -x "$process_name" >/dev/null; then
echo "$process_name is not running. Restarting..."

View File

@@ -1,7 +1,7 @@
#!/bin/bash
ProcList="restagent crontask sshsvc captrace kvdb"
ProcListDesc="kvdb crontask sshsvc captrace restagent"
ProcList="omc kvdb"
ProcListDesc="kvdb omc"
BinDir=/usr/local/omc/bin

View File

@@ -16,7 +16,7 @@ fi
case "${extension}" in
deb)
if [ ${neType} == "OMC" ]; then
systemctl stop restagent.service
systemctl stop omc.service
fi
expect <<EOF > ${logFile}
spawn dpkg -i --force-all "$filename"
@@ -32,7 +32,7 @@ EOF
;;
rpm)
if [ ${neType} == "OMC" ]; then
systemctl stop restagent.service
systemctl stop omc.service
fi
expect <<EOF > ${logFile}
spawn rpm -Uvh "$filename"

View File

@@ -3,7 +3,7 @@
# duration: rotation time with xx hours, example: 1/12/24 hours
# count: rotation count of log, default is 30 rotation
logger:
file: /usr/local/omc/log/restagent.log
file: /usr/local/omc/log/omc.log
level: warn
duration: 24
count: 90
@@ -13,17 +13,9 @@ logger:
# clientAuthType: 0:NoClientCert (default), 1:RequestClientCert, 2:RequireAnyClientCert,
# 3:VerifyClientCertIfGiven, 4:RequireAndVerifyClientCerts
rest:
- ipv4: 0.0.0.0
- ipv4: 127.0.0.1
ipv6:
port: 33030
- ipv4: 0.0.0.0
ipv6:
port: 33443
schema: https
clientAuthType: 0
caFile: /usr/local/omc/etc/certs/omc-ca.crt
certFile: /usr/local/omc/etc/certs/omc-server.crt
keyFile: /usr/local/omc/etc/certs/omc-server.key
webServer:
enabled: false

View File

@@ -862,7 +862,7 @@ func PostNeServiceAction(w http.ResponseWriter, r *http.Request) {
// send 204 to fe firstly
services.ResponseStatusOK204NoContent(w)
//actionCmd := fmt.Sprintf("sudo %s/bin/omcsvc.sh %s", config.GetYamlConfig().NE.OmcDir, action)
actionCmd := fmt.Sprintf("sudo systemctl %s restagent", action)
actionCmd := fmt.Sprintf("sudo systemctl %s omc", action)
go RunSSHCmd(sshHost, actionCmd)
return
// cmd := exec.Command("ssh", sshHost, actionCmd)

View File

@@ -370,7 +370,7 @@ func ReadTestConfigYaml(pfile string) (ret error) {
}
func GetDefaultUserAgent() string {
return "OMC-restagent/" + global.Version
return "OMC/" + global.Version
}
func GetOMCHostUrl() string {
@@ -389,34 +389,3 @@ func GetOMCHostUrl() string {
return fmt.Sprintf("%s://%s:%d", scheme, omcip, port)
}
// const defaultConfigFile = "./etc/restconf.yaml"
// func init() {
// cfile := flag.String("c", defaultConfigFile, "config file")
// pv := flag.Bool("version", false, "print version")
// ph := flag.Bool("help", false, "print help")
// //global.BuildTime = "Wed May 31 18:24:04 CST 2023"
// //global.GoVer = "go version go1.15.7 linux/arm64"
// flag.Parse()
// if *pv {
// fmt.Printf("OMC restagent version: %s\n%s\n%s\n\n", global.Version, global.BuildTime, global.GoVer)
// os.Exit(0)
// }
// if *ph {
// flag.Usage()
// os.Exit(0)
// }
// // 使用viper读取配置
// conf.InitConfig(*cfile)
// ReadConfig(*cfile)
// if GetYamlConfig().OMC.UriPrefix != "" {
// UriPrefix = GetYamlConfig().OMC.UriPrefix
// }
// if GetYamlConfig().TestConfig.Enabled {
// ReadTestConfigYaml(GetYamlConfig().TestConfig.File)
// }
// }

View File

@@ -155,9 +155,9 @@ func main() {
}
log.InitLogger(conf.Logger.File, conf.Logger.Duration, conf.Logger.Count, "omc:", config.GetLogLevel())
fmt.Printf("OMC restagent version: %s\n", global.Version)
fmt.Printf("OMC version: %s\n", global.Version)
log.Infof("========================= OMC startup =========================")
log.Infof("OMC restagent version: %s %s %s", global.Version, global.BuildTime, global.GoVer)
log.Infof("OMC version: %s %s %s", global.Version, global.BuildTime, global.GoVer)
err := dborm.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)

View File

@@ -164,7 +164,7 @@ func Reset() error {
return err
}
// 重启服务
if _, err := cmd.Execf("nohup sh -c \"sleep 1s && %s\" > /dev/null 2>&1 &", "sudo systemctl restart restagent"); err != nil {
if _, err := cmd.Execf("nohup sh -c \"sleep 1s && %s\" > /dev/null 2>&1 &", "sudo systemctl restart omc"); err != nil {
return err
}
}

View File

@@ -1,4 +1,4 @@
# 外层 lib 和 features 粘合层
- config.go 配置合并: restagent.yaml 文件内容,主要是数据库配置
- config.go 配置合并: omc.yaml 文件内容,主要是数据库配置

View File

@@ -221,7 +221,7 @@ func (s *NeActionController) Service(c *gin.Context) {
neTypeLower := strings.ToLower(neInfo.NeType)
cmdStr := fmt.Sprintf("sudo service %s %s", neTypeLower, body.Action)
if neTypeLower == "omc" {
cmdStr = fmt.Sprintf("nohup sh -c \"sudo systemctl stop restagent && sleep 5s && sudo systemctl %s restagent\" > /dev/null 2>&1 &", body.Action)
cmdStr = fmt.Sprintf("nohup sh -c \"sudo systemctl stop omc && sleep 5s && sudo systemctl %s omc\" > /dev/null 2>&1 &", body.Action)
} else if neTypeLower == "ims" {
if body.Action == "restart" {
cmdStr = "ims-stop || true && ims-start"

View File

@@ -183,7 +183,7 @@ func (r *NeLicenseImpl) UploadLicense(neLicense model.NeLicense) error {
if neTypeLower == "ims" {
cmdStr = "ims-stop || true && ims-start"
} else if neTypeLower == "omc" {
cmdStr = "sudo systemctl restart restagent"
cmdStr = "sudo systemctl restart omc"
}
sshClient.RunCMD(cmdStr)
}

View File

@@ -207,7 +207,7 @@ func (r *NeVersionImpl) operateCommand(action, neType string, neFilePaths []stri
} else {
omcStrArr = append(omcStrArr, "sudo /usr/local/omc/bin/setomc.sh -m upgrade") // 升级数据库
}
omcStrArr = append(omcStrArr, "sudo systemctl restart restagent") // 重启服务
omcStrArr = append(omcStrArr, "sudo systemctl restart omc") // 重启服务
omcStrArr = append(omcStrArr, fmt.Sprintf("sudo rm %s", strings.Join(neFilePaths, " "))) // 删除软件包
// 2s后安装

View File

@@ -510,7 +510,7 @@ func (s *ConfigImpl) paramModifyBase(neInfo neModel.NeInfo, operPara map[string]
neTypeLower := strings.ToLower(neInfo.NeType)
cmdStr := fmt.Sprintf("sudo service %s restart", neTypeLower)
if neTypeLower == "omc" {
cmdStr = "nohup sh -c \"sudo systemctl stop restagent && sleep 5s && sudo systemctl restart restagent\" > /dev/null 2>&1 &"
cmdStr = "nohup sh -c \"sudo systemctl stop omc && sleep 5s && sudo systemctl restart omc\" > /dev/null 2>&1 &"
} else if neTypeLower == "ims" {
cmdStr = "ims-stop || true && ims-start"
}