(task *task.Task, appInstall *model.AppInstall, operate string)
| 1133 | } |
| 1134 | |
| 1135 | func 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 | |
| 1163 | func checkContainerNameIsExist(containerName, appDir string) (bool, error) { |
| 1164 | client, err := docker.NewDockerClient() |
no test coverage detected