fix: 网元授权文件上传目录权限修改
This commit is contained in:
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -174,17 +175,17 @@ func (r *NeLicenseImpl) UploadLicense(neLicense model.NeLicense) error {
|
||||
|
||||
// 网元端授权文件路径
|
||||
neTypeLower := strings.ToLower(neLicense.NeType)
|
||||
neLicensePath := fmt.Sprintf("/usr/local/etc/%s/license", neTypeLower)
|
||||
// 修改文件夹权限
|
||||
sshClient.RunCMD(fmt.Sprintf("sudo chmod o+w %s/", neLicensePath))
|
||||
sshClient.RunCMD(fmt.Sprintf("sudo chmod o+w %s/system.ini", neLicensePath))
|
||||
neLicensePath := fmt.Sprintf("/usr/local/etc/%s/license/system.ini", neTypeLower)
|
||||
neLicenseDir := filepath.ToSlash(filepath.Dir(neLicensePath))
|
||||
// 修改网元文件权限
|
||||
sshClient.RunCMD(fmt.Sprintf("sudo chmod o+w %s && sudo chmod o+w %s", neLicenseDir, neLicensePath))
|
||||
|
||||
// 尝试备份授权文件
|
||||
neLicensePathBack := fmt.Sprintf("%s/system_%s.ini", neLicensePath, time.Now().Format("20060102_150405"))
|
||||
sshClient.RunCMD(fmt.Sprintf("sudo cp -rf %s/system.ini %s", neLicensePath, neLicensePathBack))
|
||||
|
||||
// 上传授权文件去覆盖
|
||||
err = sftpClient.CopyFileLocalToRemote(omcLicensePath, neLicensePath+"/system.ini")
|
||||
if err != nil {
|
||||
if err := sftpClient.CopyFileLocalToRemote(omcLicensePath, neLicensePath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -192,7 +193,7 @@ func (r *NeLicenseImpl) UploadLicense(neLicense model.NeLicense) error {
|
||||
if neLicense.Reload {
|
||||
cmdStr := fmt.Sprintf("sudo service %s restart", neTypeLower)
|
||||
if neTypeLower == "ims" {
|
||||
cmdStr = "sudo ims-stop && sudo ims-start"
|
||||
cmdStr = "sudo ims-stop || true && sudo ims-start"
|
||||
} else if neTypeLower == "omc" {
|
||||
cmdStr = "sudo /usr/local/omc/bin/omcsvc.sh restart"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user