Compare commits
5 Commits
85f7e3e4d8
...
2.2410.3-2
| Author | SHA1 | Date | |
|---|---|---|---|
| 0adc47628f | |||
| 18701c7c41 | |||
| 9e5b4c1bf1 | |||
| 587e7a65f0 | |||
| 7be1132430 |
8
.vscode/launch.json
vendored
8
.vscode/launch.json
vendored
@@ -18,7 +18,7 @@
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "d:/local.git/be.ems/restagent/",
|
||||
"program": "d:/omc.git/be.ems/restagent/",
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
@@ -26,7 +26,7 @@
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "d:/local.git/be.ems/sshsvc/sshsvc.go",
|
||||
"program": "d:/omc.git/be.ems/sshsvc/sshsvc.go",
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
@@ -34,7 +34,7 @@
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "d:/local.git/be.ems/crontask",
|
||||
"program": "d:/omc.git/be.ems/crontask",
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
@@ -42,7 +42,7 @@
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "d:/local.git/be.ems/tools/encode",
|
||||
"program": "d:/omc.git/be.ems/tools/encode",
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 版本发布日志
|
||||
|
||||
## 2.2410.2-20241018
|
||||
## 2.2410.3-20241018
|
||||
|
||||
- 新增 网元主机支持redis配置项
|
||||
- 新增 菜单功能iperf3/ping网络测试工具
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# level: /trace/debug/info/error/warn/error/fatal, default: debug
|
||||
# duration: saved days, default is 30 days
|
||||
logger:
|
||||
file: d:/local.git/be.ems/captrace/log/captrace.log
|
||||
file: d:/omc.git/be.ems/captrace/log/captrace.log
|
||||
level: trace
|
||||
duration: 24
|
||||
count: 10
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for rest agent project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2410.2
|
||||
VERSION = 2.2410.3
|
||||
PLATFORM = amd64
|
||||
ARMPLATFORM = aarch64
|
||||
BUILDDIR = ../../build
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# level: /trace/debug/info/error/warn/error/fatal, default: debug
|
||||
# duration: saved days, default is 30 days
|
||||
logger:
|
||||
file: d:/local.git/be.ems/crontask/log/crontask.log
|
||||
file: d:/omc.git/be.ems/crontask/log/crontask.log
|
||||
level: trace
|
||||
duration: 24
|
||||
count: 10
|
||||
@@ -26,7 +26,7 @@ database:
|
||||
port: 33066
|
||||
name: omc_db
|
||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||
backup: d:/local.git/be.ems/restagent/database
|
||||
backup: d:/omc.git/be.ems/restagent/database
|
||||
|
||||
# northbound interface, cm/pm
|
||||
# duration(day): saved days
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for OMC-OMC-crontask project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2410.2
|
||||
VERSION = 2.2410.3
|
||||
LIBDIR = be.ems/lib
|
||||
BINNAME = crontask
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for rest agent project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2410.2
|
||||
VERSION = 2.2410.3
|
||||
RelDate = `date +%Y%m%d`
|
||||
Release = $(RelDate)
|
||||
RelVer = $(VERSION)-$(RelDate)
|
||||
|
||||
@@ -3,6 +3,7 @@ package features
|
||||
import (
|
||||
"be.ems/features/cm"
|
||||
"be.ems/features/lm"
|
||||
"be.ems/features/nbi"
|
||||
"be.ems/features/pm"
|
||||
"be.ems/lib/log"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -12,10 +13,10 @@ func InitServiceEngine(r *gin.Engine) {
|
||||
log.Info("======init feature group gin.Engine")
|
||||
|
||||
// featuresGroup := r.Group("/")
|
||||
// 注册 各个features 模块的路由
|
||||
// register features routers
|
||||
pm.InitSubServiceRoute(r)
|
||||
lm.InitSubServiceRoute(r)
|
||||
cm.InitSubServiceRoute(r)
|
||||
|
||||
nbi.InitSubServiceRoute(r)
|
||||
// return featuresGroup
|
||||
}
|
||||
|
||||
257
features/nbi/file/controller.go
Normal file
257
features/nbi/file/controller.go
Normal file
@@ -0,0 +1,257 @@
|
||||
package nbi_file
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"be.ems/lib/dborm"
|
||||
"be.ems/lib/file"
|
||||
"be.ems/lib/global"
|
||||
"be.ems/lib/log"
|
||||
"be.ems/lib/services"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type SysJobResponse struct {
|
||||
SysJob
|
||||
TableName string `json:"tableName"`
|
||||
TableDisplay string `json:"tableDisplay"`
|
||||
FilePath string `json:"filePath"`
|
||||
}
|
||||
|
||||
type TargetParams struct {
|
||||
Duration int `json:"duration"`
|
||||
TableName string `json:"tableName"`
|
||||
Columns string `json:"columns"` // exported column name of time string
|
||||
TimeCol string `json:"timeCol"` // time stamp of column name
|
||||
TimeUnit string `json:"timeUnit"` // timestamp unit: second/micro/milli
|
||||
Extras string `json:"extras"` // extras condition for where
|
||||
FilePath string `json:"filePath"` // file path
|
||||
}
|
||||
|
||||
func (m *FileNBI) GetFileList(c *gin.Context) {
|
||||
var querys FileNBIQuery
|
||||
|
||||
querys.Category = c.Param("category")
|
||||
querys.Type = c.Param("type")
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if querys.Path == "" {
|
||||
tableName := ""
|
||||
ok := false
|
||||
switch querys.Category {
|
||||
case "cdr":
|
||||
tableName, ok = CDRTableMapper[querys.Type]
|
||||
if tableName == "" || !ok {
|
||||
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid CDR file type: %s", querys.Type)))
|
||||
return
|
||||
}
|
||||
case "log":
|
||||
tableName, ok = LogTableMapper[querys.Type]
|
||||
if tableName == "" || !ok {
|
||||
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file type: %s", querys.Type)))
|
||||
return
|
||||
}
|
||||
default:
|
||||
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file category: %s", querys.Category)))
|
||||
return
|
||||
}
|
||||
|
||||
s := SysJob{}
|
||||
where := fmt.Sprintf("invoke_target='%s' and status=1 and JSON_UNQUOTE(JSON_EXTRACT(target_params,'$.tableName'))='%s'", INVOKE_FILE_EXPORT, tableName)
|
||||
_, err := dborm.XEngDB().Table(s.TableName()).
|
||||
Select("JSON_UNQUOTE(JSON_EXTRACT(target_params, '$.filePath')) as file_path").
|
||||
Where(where).
|
||||
Get(&querys.Path)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
files, err := file.GetFileInfo(querys.Path, querys.Suffix)
|
||||
if err != nil {
|
||||
log.Error("failed to GetFileInfo:", err)
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
// split files list
|
||||
lenNum := int64(len(files))
|
||||
start := (querys.PageNum - 1) * querys.PageSize
|
||||
end := start + querys.PageSize
|
||||
var splitList []file.FileInfo
|
||||
if start >= lenNum {
|
||||
splitList = []file.FileInfo{}
|
||||
} else if end >= lenNum {
|
||||
splitList = files[start:]
|
||||
} else {
|
||||
splitList = files[start:end]
|
||||
}
|
||||
total := len(files)
|
||||
c.JSON(http.StatusOK, services.TotalDataResp(splitList, total))
|
||||
}
|
||||
|
||||
func (m *FileNBI) Total(c *gin.Context) {
|
||||
dir := c.Query("path")
|
||||
|
||||
fileCount, dirCount, err := file.GetFileAndDirCount(dir)
|
||||
if err != nil {
|
||||
log.Error("failed to GetFileAndDirCount:", err)
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
total := fileCount + dirCount
|
||||
c.JSON(http.StatusOK, services.TotalResp(int64(total)))
|
||||
}
|
||||
|
||||
func (m *FileNBI) GetSingleFileHandler(c *gin.Context) {
|
||||
var querys FileNBIQuery
|
||||
|
||||
querys.Category = c.Param("category")
|
||||
querys.Type = c.Param("type")
|
||||
querys.DateIndex = c.Param("dateIndex")
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
tableName := ""
|
||||
if querys.Path == "" {
|
||||
ok := false
|
||||
switch querys.Category {
|
||||
case "cdr":
|
||||
tableName, ok = CDRTableMapper[querys.Type]
|
||||
if tableName == "" || !ok {
|
||||
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid CDR file type: %s", querys.Type)))
|
||||
return
|
||||
}
|
||||
case "log":
|
||||
tableName, ok = LogTableMapper[querys.Type]
|
||||
if tableName == "" || !ok {
|
||||
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file type: %s", querys.Type)))
|
||||
return
|
||||
}
|
||||
default:
|
||||
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file category: %s", querys.Category)))
|
||||
return
|
||||
}
|
||||
|
||||
s := SysJob{}
|
||||
where := fmt.Sprintf("invoke_target='%s' and status=1 and JSON_UNQUOTE(JSON_EXTRACT(target_params,'$.tableName'))='%s'", INVOKE_FILE_EXPORT, tableName)
|
||||
_, err := dborm.XEngDB().Table(s.TableName()).
|
||||
Select("JSON_UNQUOTE(JSON_EXTRACT(target_params, '$.filePath')) as file_path").
|
||||
Where(where).
|
||||
Get(&querys.Path)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
fileName := tableName + "_export_" + querys.DateIndex + "0000" + ".csv"
|
||||
filePath := filepath.Join(querys.Path, fileName)
|
||||
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
c.Header("Content-Disposition", "attachment; filename="+fileName)
|
||||
c.Header("Content-Type", "application/octet-stream")
|
||||
c.File(filePath)
|
||||
}
|
||||
|
||||
func (m *FileNBI) GetMultiFileHandler(c *gin.Context) {
|
||||
var querys FileNBIQuery
|
||||
|
||||
querys.Category = c.Param("category")
|
||||
querys.Type = c.Param("type")
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
tableName := ""
|
||||
if querys.Path == "" {
|
||||
ok := false
|
||||
switch querys.Category {
|
||||
case "cdr":
|
||||
tableName, ok = CDRTableMapper[querys.Type]
|
||||
if tableName == "" || !ok {
|
||||
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid CDR file type: %s", querys.Type)))
|
||||
return
|
||||
}
|
||||
case "log":
|
||||
tableName, ok = LogTableMapper[querys.Type]
|
||||
if tableName == "" || !ok {
|
||||
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file type: %s", querys.Type)))
|
||||
return
|
||||
}
|
||||
default:
|
||||
c.JSON(http.StatusOK, services.ErrResp(fmt.Sprintf("invalid log file category: %s", querys.Category)))
|
||||
return
|
||||
}
|
||||
|
||||
s := SysJob{}
|
||||
where := fmt.Sprintf("invoke_target='%s' and status=1 and JSON_UNQUOTE(JSON_EXTRACT(target_params,'$.tableName'))='%s'", INVOKE_FILE_EXPORT, tableName)
|
||||
_, err := dborm.XEngDB().Table(s.TableName()).
|
||||
Select("JSON_UNQUOTE(JSON_EXTRACT(target_params, '$.filePath')) as file_path").
|
||||
Where(where).
|
||||
Get(&querys.Path)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
zipWriter := zip.NewWriter(c.Writer)
|
||||
defer zipWriter.Close()
|
||||
|
||||
for _, fileName := range querys.FileNames {
|
||||
filePath := filepath.Join(querys.Path, fileName)
|
||||
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
writer, err := zipWriter.Create(filepath.Base(fileName))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := io.Copy(writer, file); err != nil {
|
||||
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
zipFile := tableName + "_export_" + time.Now().Local().Format(global.DateData) + ".zip"
|
||||
c.Header("Content-Disposition", "attachment; filename="+zipFile)
|
||||
c.Header("Content-Type", "application/zip")
|
||||
//c.File(filePath)
|
||||
}
|
||||
47
features/nbi/file/model.go
Normal file
47
features/nbi/file/model.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package nbi_file
|
||||
|
||||
import (
|
||||
"be.ems/lib/file"
|
||||
)
|
||||
|
||||
const (
|
||||
INVOKE_FILE_EXPORT = "exportTable"
|
||||
)
|
||||
|
||||
var CDRTableMapper map[string]string = map[string]string{
|
||||
"ims": "cdr_event_ims",
|
||||
"smf": "cdr_event_smf",
|
||||
"smsc": "cdr_event_smsc",
|
||||
"sms": "cdr_event_smsc",
|
||||
}
|
||||
|
||||
var LogTableMapper map[string]string = map[string]string{
|
||||
"operate": "sys_log_operate",
|
||||
"security": "sys_log_login",
|
||||
"alarm": "alarm_log",
|
||||
}
|
||||
|
||||
type SysJob struct {
|
||||
JobID int64 `gorm:"column:job_id;primary_key;auto_increment" json:"job_id"` //任务ID
|
||||
InvokeTarget string `gorm:"column:invoke_target" json:"invoke_target"` //调用目标字符串
|
||||
TargetParams string `gorm:"column:target_params;type:json" json:"target_params,omitempty"` //调用目标传入参数
|
||||
}
|
||||
|
||||
func (s *SysJob) TableName() string {
|
||||
return "sys_job"
|
||||
}
|
||||
|
||||
type FileNBI struct {
|
||||
file.FileInfo
|
||||
}
|
||||
|
||||
type FileNBIQuery struct {
|
||||
Category string `form:"category" binding:"required"`
|
||||
Type string `form:"type" binding:"required"`
|
||||
DateIndex string `form:"dateIndex"`
|
||||
Path string `json:"path" form:"path"`
|
||||
FileNames []string `json:"fileName" form:"fileName"`
|
||||
Suffix string `form:"suffix"`
|
||||
PageNum int64 `form:"pageNum"`
|
||||
PageSize int64 `form:"pageSize"`
|
||||
}
|
||||
26
features/nbi/file/route.go
Normal file
26
features/nbi/file/route.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package nbi_file
|
||||
|
||||
import (
|
||||
"be.ems/src/framework/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Register Routes for file_export
|
||||
func Register(r *gin.RouterGroup) {
|
||||
fileNBI := r.Group("/file")
|
||||
{
|
||||
var f *FileNBI
|
||||
fileNBI.GET("/:category/:type/list",
|
||||
middleware.PreAuthorize(nil),
|
||||
f.GetFileList,
|
||||
)
|
||||
fileNBI.GET("/:category/:type/:dateIndex",
|
||||
middleware.PreAuthorize(nil),
|
||||
f.GetSingleFileHandler,
|
||||
)
|
||||
fileNBI.GET("/:category/:type",
|
||||
middleware.PreAuthorize(nil),
|
||||
f.GetMultiFileHandler,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
"be.ems/lib/log"
|
||||
"be.ems/lib/oauth"
|
||||
"be.ems/lib/services"
|
||||
"be.ems/lib/session"
|
||||
"be.ems/restagent/config"
|
||||
)
|
||||
|
||||
@@ -35,7 +34,7 @@ type ApiResponse struct {
|
||||
ResultMessage interface{}
|
||||
}
|
||||
|
||||
var globalSession = session.NewSessManager("restagent")
|
||||
//var globalSession = session.NewSessManager("restagent")
|
||||
|
||||
var (
|
||||
MAX_RMUID_NUM int
|
||||
|
||||
16
features/nbi/service.go
Normal file
16
features/nbi/service.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// log management package
|
||||
|
||||
package nbi
|
||||
|
||||
import (
|
||||
nbi_file "be.ems/features/nbi/file"
|
||||
"be.ems/lib/log"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func InitSubServiceRoute(r *gin.Engine) {
|
||||
log.Info("======init North-Bound Interface group gin.Engine")
|
||||
|
||||
nbiGroup := r.Group("/nbi")
|
||||
nbi_file.Register(nbiGroup)
|
||||
}
|
||||
@@ -54,28 +54,28 @@ func GetNRMByUri(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// error processing ...
|
||||
// 401-1 response
|
||||
token, ret := globalSession.IsCarriedToken(r)
|
||||
if ret == false {
|
||||
log.Error("AccessToken is not carried")
|
||||
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||
return
|
||||
}
|
||||
// token, ret := globalSession.IsCarriedToken(r)
|
||||
// if ret == false {
|
||||
// log.Error("AccessToken is not carried")
|
||||
// services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||
// return
|
||||
// }
|
||||
|
||||
// 401-2 response
|
||||
if globalSession.IsValidToken(token) == false {
|
||||
log.Error("AccessToken fails or does not exist")
|
||||
services.ResponseUnauthorized401AccessTokenNotExist(w)
|
||||
return
|
||||
}
|
||||
// if globalSession.IsValidToken(token) == false {
|
||||
// log.Error("AccessToken fails or does not exist")
|
||||
// services.ResponseUnauthorized401AccessTokenNotExist(w)
|
||||
// return
|
||||
// }
|
||||
// response 403 Forbidden, permissions deny
|
||||
// todo...
|
||||
plist := globalSession.GetPermissionFromSession(token)
|
||||
log.Debug("permission list:", plist)
|
||||
if len(plist) == 0 || plist[0] == false {
|
||||
log.Error("User permission deny")
|
||||
services.ResponseForbidden403NotPermission(w)
|
||||
return
|
||||
}
|
||||
// plist := globalSession.GetPermissionFromSession(token)
|
||||
// log.Debug("permission list:", plist)
|
||||
// if len(plist) == 0 || plist[0] == false {
|
||||
// log.Error("User permission deny")
|
||||
// services.ResponseForbidden403NotPermission(w)
|
||||
// return
|
||||
// }
|
||||
|
||||
vars := mux.Vars(r)
|
||||
qeuryUri := vars["apiCategory"] + "/" + vars["elementTypeValue"] + "/" + vars["objectTypeValue"]
|
||||
|
||||
@@ -9,14 +9,15 @@ import (
|
||||
)
|
||||
|
||||
type FileInfo struct {
|
||||
FileType string `json:"fileType"` // 文件类型
|
||||
FileMode string `json:"fileMode"` // 文件的权限
|
||||
LinkCount int64 `json:"linkCount"` // 硬链接数目
|
||||
Owner string `json:"owner"` // 所属用户
|
||||
Group string `json:"group"` // 所属组
|
||||
Size int64 `json:"size"` // 文件的大小
|
||||
ModifiedTime int64 `json:"modifiedTime"` // 最后修改时间,单位为秒
|
||||
FileName string `json:"fileName"` // 文件的名称
|
||||
FileType string `json:"fileType"` // file type: file/directory
|
||||
FileMode string `json:"fileMode"` // file mode
|
||||
LinkCount int64 `json:"linkCount"` // link count
|
||||
Owner string `json:"owner"` // owner
|
||||
Group string `json:"group"` // group
|
||||
Size int64 `json:"size"` // size: xx byte
|
||||
ModifiedTime int64 `json:"modifiedTime"` // last modified time:seconds
|
||||
FilePath string `json:"filePath"` // file path
|
||||
FileName string `json:"fileName"` // file name
|
||||
}
|
||||
|
||||
func GetFileInfo(dir, suffix string) ([]FileInfo, error) {
|
||||
@@ -48,6 +49,7 @@ func GetFileInfo(dir, suffix string) ([]FileInfo, error) {
|
||||
Group: "-",
|
||||
Size: info.Size(),
|
||||
ModifiedTime: info.ModTime().Unix(),
|
||||
FilePath: dir,
|
||||
FileName: info.Name(),
|
||||
}
|
||||
files = append(files, fileInfo)
|
||||
|
||||
4
makefile
4
makefile
@@ -3,13 +3,13 @@
|
||||
ProjectL = omc
|
||||
ProjectU = OMC
|
||||
PROJECT = $(ProjectL)
|
||||
VERSION = 2.2410.2
|
||||
VERSION = 2.2410.3
|
||||
RelDate = `date +%Y%m%d`
|
||||
Release = $(RelDate)
|
||||
RelVer = $(VERSION)-$(RelDate)
|
||||
PLATFORM = amd64
|
||||
ARMPLATFORM = aarch64
|
||||
GitLocalRoot = $(HOME)/local.git
|
||||
GitLocalRoot = $(HOME)/omc.git
|
||||
EmsBuildRoot=$(GitLocalRoot)/build.ems
|
||||
BuildDir = $(EmsBuildRoot)/build
|
||||
BuildOMCDir = $(BuildDir)/usr/local/omc
|
||||
|
||||
62
misc/upgconf.sh
Normal file
62
misc/upgconf.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
config_file="/usr/local/omc/etc/restconf.yaml"
|
||||
temp_file="/tmp/temp.yaml"
|
||||
|
||||
declare -A insert_lines=(
|
||||
[156]=" dataCoding: 0"
|
||||
[157]=" serviceNumber: \"OMC\""
|
||||
)
|
||||
|
||||
declare -A update_lines=(
|
||||
["deadLine: 10"]="deadLine: 600"
|
||||
)
|
||||
|
||||
# check if exist file
|
||||
if [[ ! -f $config_file ]]; then
|
||||
echo "NOT FOUND config file: $config_file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
insert_if_missing() {
|
||||
local line_number="$1"
|
||||
local line_content="$2"
|
||||
local current_content=$(sed -n "${line_number}p" "$config_file")
|
||||
|
||||
if [[ "$current_content" != "$line_content" ]]; then
|
||||
# insert line to config file
|
||||
echo -n "Inserting '$line_content' into line ${line_number} ... "
|
||||
awk -v n="$line_number" -v line="$line_content" 'NR==n {print line} {print}' "$config_file" >"$temp_file" && mv "$temp_file" "$config_file"
|
||||
if [ $? = 0 ]; then
|
||||
echo "done"
|
||||
fi
|
||||
else
|
||||
echo "Exist '$line_content' at line ${line_number}"
|
||||
fi
|
||||
}
|
||||
|
||||
# function:update line content
|
||||
update_lines_content() {
|
||||
local old_line="$1"
|
||||
local new_line="$2"
|
||||
echo -n "Updating '$old_line' to line '$new_line' ..."
|
||||
sed -i "s/$old_line/$new_line/" "$config_file"
|
||||
if [ $? = 0 ]; then
|
||||
echo "done"
|
||||
fi
|
||||
}
|
||||
|
||||
#line_numbers=(156 157)
|
||||
line_numbers=$(for key in "${!insert_lines[@]}"; do echo "$key"; done | sort -n)
|
||||
|
||||
# insert process
|
||||
#for line_number in "${line_numbers[@]}"; do
|
||||
#for line_number in "${!insert_lines[@]}"; do
|
||||
for line_number in $line_numbers; do
|
||||
insert_if_missing "$line_number" "${insert_lines[$line_number]}"
|
||||
done
|
||||
|
||||
# update process
|
||||
for old_line in "${!update_lines[@]}"; do
|
||||
update_lines_content "$old_line" "${update_lines[$old_line]}"
|
||||
done
|
||||
4
mkpkg.sh
4
mkpkg.sh
@@ -2,7 +2,7 @@
|
||||
|
||||
ProcList="restagent crontask sshsvc captrace data2html"
|
||||
ProjectL=omc
|
||||
VERSION=2.2410.2
|
||||
VERSION=2.2410.3
|
||||
RelDate=`date +%Y%m%d`
|
||||
Release=${RelDate}
|
||||
RelVer=${VERSION}-${RelDate}
|
||||
@@ -10,7 +10,7 @@ Ky10Arch=ky10.aarch64
|
||||
RpmPkgName=${ProjectL}-${RelVer}.ky10.aarch64.rpm
|
||||
RpmPkgRename=${ProjectL}-r${RelVer}-ky10.rpm
|
||||
DebPkgName=${ProjectL}-r${RelVer}-ub*.deb
|
||||
GitLocalRoot=${HOME}/local.git
|
||||
GitLocalRoot=${HOME}/omc.git
|
||||
EmsBEDir=${GitLocalRoot}/be.ems
|
||||
EmsBuildRoot=${GitLocalRoot}/build.ems
|
||||
RpmArch=`arch`
|
||||
|
||||
@@ -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: d:/local.git/be.ems/restagent/log/restagent.log
|
||||
file: d:/omc.git/be.ems/restagent/log/restagent.log
|
||||
level: trace
|
||||
duration: 24
|
||||
count: 2
|
||||
@@ -27,7 +27,7 @@ rest:
|
||||
|
||||
webServer:
|
||||
enabled: false
|
||||
rootDir: d:/local.git/fe.ems.vue3/dist
|
||||
rootDir: d:/omc.git/fe.ems.vue3/dist
|
||||
listen:
|
||||
- addr: :80
|
||||
schema: http
|
||||
@@ -46,7 +46,7 @@ database:
|
||||
port: 33066
|
||||
name: omc_db
|
||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||
backup: d:/local.git/be.ems/restagent/database
|
||||
backup: d:/omc.git/be.ems/restagent/database
|
||||
|
||||
# Redis 缓存数据,数据源声明全小写
|
||||
redis:
|
||||
@@ -113,8 +113,8 @@ omc:
|
||||
binDir: ./bin
|
||||
backup: ./backup
|
||||
upload: ./upload
|
||||
frontUpload: d:/local.git/fe.ems/upload
|
||||
frontTraceDir: d:/local.git/fe.ems/trace
|
||||
frontUpload: d:/omc.git/fe.ems/upload
|
||||
frontTraceDir: d:/omc.git/fe.ems/trace
|
||||
software: ./software
|
||||
license: ./license
|
||||
gtpUri: gtp:192.168.2.219:2152
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# count: rotation count of log, default is 30 rotation
|
||||
# pprof: false(default)/true to disable/enable pprof
|
||||
logger:
|
||||
file: d:/local.git/be.ems/restagent/log/restagent.log
|
||||
file: d:/omc.git/be.ems/restagent/log/restagent.log
|
||||
level: trace
|
||||
duration: 24
|
||||
count: 2
|
||||
@@ -24,7 +24,7 @@ rest:
|
||||
|
||||
webServer:
|
||||
enabled: true
|
||||
rootDir: d:/local.git/fe.ems.vue3/dist
|
||||
rootDir: d:/omc.git/fe.ems.vue3/dist
|
||||
listen:
|
||||
- addr: :80
|
||||
schema: http
|
||||
@@ -43,7 +43,7 @@ database:
|
||||
port: 33066
|
||||
name: "omc_db"
|
||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||
backup: d:/local.git/be.ems/restagent/database
|
||||
backup: d:/omc.git/be.ems/restagent/database
|
||||
|
||||
# Redis data cache
|
||||
redis:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for rest agent project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2410.2
|
||||
VERSION = 2.2410.3
|
||||
PLATFORM = amd64
|
||||
ARMPLATFORM = aarch64
|
||||
BUILDDIR = ../../build
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# 项目信息
|
||||
framework:
|
||||
name: "OMC"
|
||||
version: "2.2410.2"
|
||||
version: "2.2410.3"
|
||||
|
||||
# 应用服务配置
|
||||
server:
|
||||
|
||||
@@ -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: d:/local.git/be.ems/sshsvc/log/sshsvc.log
|
||||
file: d:/omc.git/be.ems/sshsvc/log/sshsvc.log
|
||||
level: trace
|
||||
duration: 24
|
||||
count: 30
|
||||
@@ -13,7 +13,7 @@ logger:
|
||||
# count: rotation count of log, default is 30 rotation
|
||||
# level: cmd/ret log cmd/log cmd & result
|
||||
logmml:
|
||||
file: d:/local.git/be.ems/sshsvc/mmllog/omcmml.log
|
||||
file: d:/omc.git/be.ems/sshsvc/mmllog/omcmml.log
|
||||
duration: 24
|
||||
count: 30
|
||||
level: ret
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for OMC-OMC-crontask project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2410.2
|
||||
VERSION = 2.2410.3
|
||||
LIBDIR = be.ems/lib
|
||||
BINNAME = sshsvc
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
Home=/home/simon
|
||||
GitLocalRoot=${Home}/local.git
|
||||
GitLocalRoot=${Home}/omc.git
|
||||
EmsBEDir=${GitLocalRoot}/be.ems
|
||||
user="root"
|
||||
password="1000omc@kp!"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
Home=/home/simon
|
||||
GitLocalRoot=${Home}/local.git
|
||||
GitLocalRoot=${Home}/omc.git
|
||||
EmsBEDir=${GitLocalRoot}/be.ems
|
||||
EMSBuildDir=${GitLocalRoot}/build.ems
|
||||
user="root"
|
||||
|
||||
Reference in New Issue
Block a user