MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / runScript

Function runScript

agent/app/service/app_utils.go:1135–1161  ·  view source on GitHub ↗
(task *task.Task, appInstall *model.AppInstall, operate string)

Source from the content-addressed store, hash-verified

1133}
1134
1135func runScript(task *task.Task, appInstall *model.AppInstall, operate string) error {
1136 workDir := appInstall.GetPath()
1137 scriptPath := ""
1138 switch operate {
1139 case "init":
1140 scriptPath = path.Join(workDir, "scripts", "init.sh")
1141 case "upgrade":
1142 scriptPath = path.Join(workDir, "scripts", "upgrade.sh")
1143 case "uninstall":
1144 scriptPath = path.Join(workDir, "scripts", "uninstall.sh")
1145 }
1146 fileOp := files.NewFileOp()
1147 if !fileOp.Stat(scriptPath) {
1148 return nil
1149 }
1150 _ = fileOp.ChmodR(scriptPath, constant.DirPerm, false)
1151 logStr := i18n.GetWithName("ExecShell", operate)
1152 task.LogStart(logStr)
1153
1154 cmdMgr := cmd.NewCommandMgr(cmd.WithTimeout(10*time.Minute), cmd.WithWorkDir(workDir))
1155 if err := cmdMgr.Run("bash", scriptPath); err != nil {
1156 task.LogFailedWithErr(logStr, err)
1157 return err
1158 }
1159 task.LogSuccess(logStr)
1160 return nil
1161}
1162
1163func checkContainerNameIsExist(containerName, appDir string) (bool, error) {
1164 client, err := docker.NewDockerClient()

Callers 3

deleteAppInstallFunction · 0.85
upgradeInstallFunction · 0.85
installWithHooksMethod · 0.85

Calls 7

StatMethod · 0.95
ChmodRMethod · 0.95
RunMethod · 0.65
GetPathMethod · 0.45
LogStartMethod · 0.45
LogFailedWithErrMethod · 0.45
LogSuccessMethod · 0.45

Tested by

no test coverage detected