add: rm expired backup file and shell script

This commit is contained in:
2023-10-28 16:23:54 +08:00
parent 6fe23761ab
commit 6370076362
5 changed files with 19 additions and 1 deletions

View File

@@ -93,6 +93,8 @@ omc:
chk2ne: false
sn: 13750650
checksign: false
rootDir: /usr/local/omc
binDir: /usr/local/omc/bin
backup: /usr/local/omc/backup
upload: /usr/local/omc/upload
frontUpload: /usr/local/omc/htdocs/front/upload

View File

@@ -121,7 +121,7 @@ deb: $(BINNAME)
chmod +x $(DebBuildDir)/usr/local/omc/bin/*
#sed -i.bak 's/YYYYMMDD/$(shell date +"%Y%m%d")/g' $(DebBuildDir)/DEBIAN/control
sed -i 's/YYYYMMDD/$(shell date +"%Y%m%d")/g' $(DebBuildDir)/DEBIAN/control
sed -i '73 s/user: root/user: agtuser/g' $(DebBuildDir)/usr/local/omc/etc/default/restconf.yaml
sed -i '74 s/user: root/user: agtuser/g' $(DebBuildDir)/usr/local/omc/etc/default/restconf.yaml
dpkg -b $(DebBuildDir) $(ReleaseDebs)/$(DebPkgFile)
rpm: $(BINNAME)

View File

@@ -66,6 +66,8 @@ type YamlConfig struct {
Chk2Ne bool `yaml:"chk2ne"`
Sn string `yaml:"sn"`
CheckSign bool `yaml:"checksign"`
RootDir string `yaml:"rootDir"`
BinDir string `yaml:"binDir"`
Backup string `yaml:"backup"`
Upload string `yaml:"upload"`
FrontUpload string `yaml:"frontUpload"`

View File

@@ -93,6 +93,8 @@ omc:
chk2ne: false
sn: 13750650
checksign: false
rootDir: ./
binDir: ./bin
backup: ./backup
upload: ./upload
frontUpload: d:/local.git/fe.ems/upload

View File

@@ -5,7 +5,9 @@ import (
"fmt"
"ems.agt/lib/dborm"
"ems.agt/lib/global"
"ems.agt/lib/log"
"ems.agt/restagent/config"
"ems.agt/src/framework/cron"
)
@@ -71,7 +73,17 @@ func (s *BarProcessor) Execute(data any) (any, error) {
// delete expired files in backup directory
// todo ...
// command := fmt.Sprintf("find . -name '*.zip' -mtime +%d -type f -print | xargs rm -rf", duration)
command := fmt.Sprintf("%s/rmexpfiles.sh %s %d", config.GetYamlConfig().OMC.BinDir, config.GetYamlConfig().OMC.Backup, duration)
log.Trace("command:", command)
out, err := global.ExecCmd(command)
if err != nil {
log.Error("Faile to exec command:", err)
return nil, err
}
log.Trace("command output:", out)
// 返回结果,用于记录执行结果
return map[string]any{
"msg": "sucess",