aboutsummaryrefslogtreecommitdiff
path: root/awwan.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-10-30 19:31:06 +0700
committerShulhan <ms@kilabit.info>2023-10-30 19:31:06 +0700
commit4726a28cee89f542eb3b0569639069a05d1df6b0 (patch)
tree8ba5cd33f4f53387f183464088f98d556a9a7e45 /awwan.go
parent5b6f533771e01e992e471d0e777d542c1526cf10 (diff)
downloadawwan-4726a28cee89f542eb3b0569639069a05d1df6b0.tar.xz
all: log all execution into file
For each script execution, a file suffixed with ".log" will be created in the same directory with the same name as script file. For example, if the script is path is "a/b/c.aww" then the log file would named "a/b/c.aww.log". This is to provides history and audit in the future.
Diffstat (limited to 'awwan.go')
-rw-r--r--awwan.go16
1 files changed, 2 insertions, 14 deletions
diff --git a/awwan.go b/awwan.go
index 7d59087..8040c73 100644
--- a/awwan.go
+++ b/awwan.go
@@ -177,12 +177,6 @@ func (aww *Awwan) Local(req *Request) (err error) {
sessionDir string
)
- req.scriptPath = filepath.Clean(req.Script)
- req.scriptPath, err = filepath.Abs(req.scriptPath)
- if err != nil {
- return fmt.Errorf("%s: %w", logp, err)
- }
-
sessionDir = filepath.Dir(req.scriptPath)
ses, err = NewSession(aww, sessionDir)
@@ -210,7 +204,7 @@ func (aww *Awwan) Local(req *Request) (err error) {
log.Printf(`%s: %s`, logp, errRemove)
}
- req.mlog.Flush()
+ req.close()
}()
var pos linePosition
@@ -244,12 +238,6 @@ func (aww *Awwan) Play(req *Request) (err error) {
sshSection *config.Section
)
- req.scriptPath = filepath.Clean(req.Script)
- req.scriptPath, err = filepath.Abs(req.scriptPath)
- if err != nil {
- return fmt.Errorf("%s: %w", logp, err)
- }
-
sessionDir = filepath.Dir(req.scriptPath)
ses, err = NewSession(aww, sessionDir)
@@ -285,7 +273,7 @@ func (aww *Awwan) Play(req *Request) (err error) {
defer func() {
ses.sshc.rmdirAll(ses.sshc.dirTmp)
- req.mlog.Flush()
+ req.close()
}()
var pos linePosition