【agent-go】- 修改文件打开指令
This commit is contained in:
@@ -4,7 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"wdd.io/agent-go/a_agent"
|
"wdd.io/agent-go/a_agent"
|
||||||
"wdd.io/agent-go/a_executor/beans"
|
"wdd.io/agent-go/a_executor/beans"
|
||||||
)
|
)
|
||||||
@@ -962,7 +964,7 @@ func (op *AgentOsOperator) InstallDockerBastion() (bool, []string) {
|
|||||||
|
|
||||||
BasicRemoveFolderComplete("/root/wdd/docker")
|
BasicRemoveFolderComplete("/root/wdd/docker")
|
||||||
|
|
||||||
dockerLocalFile := OctopusAgentInstallPrefix + dockerOfflineFileName
|
dockerLocalFile := filepath.Join(OctopusAgentInstallPrefix, dockerOfflineFileName)
|
||||||
if !BasicFileExistAndNotNull(dockerLocalFile) {
|
if !BasicFileExistAndNotNull(dockerLocalFile) {
|
||||||
sprintf := fmt.Sprintf("docker offline file not exists ! => %s", dockerLocalFile)
|
sprintf := fmt.Sprintf("docker offline file not exists ! => %s", dockerLocalFile)
|
||||||
log.Error(sprintf)
|
log.Error(sprintf)
|
||||||
@@ -974,7 +976,7 @@ func (op *AgentOsOperator) InstallDockerBastion() (bool, []string) {
|
|||||||
"-vxf",
|
"-vxf",
|
||||||
dockerLocalFile,
|
dockerLocalFile,
|
||||||
"-C",
|
"-C",
|
||||||
"/root/wdd",
|
"/root/wdd/",
|
||||||
})
|
})
|
||||||
|
|
||||||
HardCodeCommandExecutor("chmod 777 -R /root/wdd/docker/*")
|
HardCodeCommandExecutor("chmod 777 -R /root/wdd/docker/*")
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/net/proxy"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -14,6 +13,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/net/proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
var RemoveForcePrefix = []string{"rm", "-rf"}
|
var RemoveForcePrefix = []string{"rm", "-rf"}
|
||||||
@@ -422,26 +423,15 @@ func BasicFileExists(filename string) bool {
|
|||||||
// BasicFileExistAndNotNull 文件不为空返回true 文件为空返回false
|
// BasicFileExistAndNotNull 文件不为空返回true 文件为空返回false
|
||||||
func BasicFileExistAndNotNull(filename string) bool {
|
func BasicFileExistAndNotNull(filename string) bool {
|
||||||
|
|
||||||
// Check if the file exists
|
// 获取文件信息
|
||||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
fileInfo, err := os.Stat(filename)
|
||||||
log.DebugF("文件 %s 不存在!", filename)
|
if err != nil {
|
||||||
|
// 如果文件不存在或其他错误,返回 false
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the file for reading
|
// 检查文件大小是否大于零
|
||||||
file, err := os.Open(filename)
|
return fileInfo.Size() > 0
|
||||||
defer file.Close()
|
|
||||||
if err != nil {
|
|
||||||
log.DebugF("文件 %s 打开有误!", filename)
|
|
||||||
return false // Handle error according to your needs
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the file size
|
|
||||||
info, _ := file.Stat()
|
|
||||||
size := info.Size()
|
|
||||||
|
|
||||||
// Check if the file is not empty
|
|
||||||
return size > 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func BasicFolderExists(folderName string) bool {
|
func BasicFolderExists(folderName string) bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user