package script
|
|
import (
|
"fmt"
|
"strings"
|
"swfs/config"
|
"swfs/util"
|
)
|
|
//根据搜索内容替换整行内容
|
func ReplaceLineContentBySearch(replaceContent string, searchContent string, scriptPath string, scriptFile string) {
|
resSearchContent := GetNowLineContent(scriptPath+"/"+scriptFile, searchContent)
|
replaceStr := "sed -ie 's/" + resSearchContent + "/" + replaceContent + "/g' " + scriptPath + "/" + scriptFile
|
util.RunScript(replaceStr)
|
}
|
|
//获取查找内容当前行内容
|
func GetNowLineContent(filePath string, searchContent string) string {
|
scriptStr := "cat " + filePath + "| grep " + searchContent
|
fmt.Println("scriptStr: ", scriptStr)
|
return strings.Split(util.RunScript(scriptStr), "\n")[0]
|
}
|
|
//启动服务
|
func StartServer(scriptPath string) {
|
//fmt.Println("sh " + scriptPath + "/" + StartServerScript)
|
util.RunScript("sh " + scriptPath + "/" + config.StartServerScript)
|
}
|
|
//停止服务
|
func StopServer(scriptPath string) {
|
//fmt.Println("sh " + scriptPath + "/" + StopServerScript)
|
util.RunScript("sh " + scriptPath + "/" + config.StopServerScript)
|
}
|