48 lines
994 B
Go
48 lines
994 B
Go
//go:build client && linux
|
|
|
|
package client
|
|
|
|
import (
|
|
"errors"
|
|
"io/fs"
|
|
"os"
|
|
"os/exec"
|
|
"path"
|
|
|
|
"repositories.action2quare.com/ayo/gocommon/logger"
|
|
)
|
|
|
|
func run_prelaunch_script(exepath string) error {
|
|
scriptPath := path.Join(path.Dir(exepath), "prelaunch.sh")
|
|
fi, err := os.Stat(scriptPath)
|
|
if errors.Is(err, fs.ErrNotExist) {
|
|
logger.Println("prelaunch.sh not exists :", scriptPath, err)
|
|
return nil
|
|
}
|
|
|
|
if fi == nil {
|
|
logger.Println("prelaunch.sh fi is nil :", scriptPath)
|
|
return nil
|
|
}
|
|
|
|
os.Chmod(scriptPath, 0777)
|
|
|
|
logger.Println("run_prelaunch_script :", "/bin/bash", scriptPath, exepath)
|
|
return exec.Command("/bin/bash", scriptPath, exepath).Run()
|
|
}
|
|
|
|
func run_postlaunch_script(exepath string) error {
|
|
scriptPath := path.Join(path.Dir(exepath), "postlaunch.sh")
|
|
fi, err := os.Stat(scriptPath)
|
|
if errors.Is(err, fs.ErrNotExist) {
|
|
return nil
|
|
}
|
|
|
|
if fi == nil {
|
|
return nil
|
|
}
|
|
|
|
os.Chmod(scriptPath, 0777)
|
|
return exec.Command("/bin/bash", scriptPath, exepath).Run()
|
|
}
|