summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2017-07-20 08:35:28 +0100
committerKatolaZ <katolaz@freaknet.org>2017-07-20 08:35:28 +0100
commit001bcbdbfff95a3edcdae21b687f58c2628116f9 (patch)
treee2ee1ad85a9b626f7696b7786c8ed6cb9673d3f3
parent7a4cdc99d9242303c84be398f8b9c296b62c0a27 (diff)
Environment variables exported. added examples/scorsh_script.sh
-rw-r--r--examples/scorsh_script.sh10
-rw-r--r--examples/worker1/worker1.cfg2
-rw-r--r--exec.go19
3 files changed, 20 insertions, 11 deletions
diff --git a/examples/scorsh_script.sh b/examples/scorsh_script.sh
new file mode 100644
index 0000000..9a563d8
--- /dev/null
+++ b/examples/scorsh_script.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+echo "SCORSH_REPO:" ${SCORSH_REPO}
+echo "SCORSH_BRANCH:" ${SCORSH_BRANCH}
+echo "SCORSH_OLDREV:" ${SCORSH_OLDREV}
+echo "SCORSH_NEWREV:" ${SCORSH_NEWREV}
+echo "SCORSH_ID:" ${SCORSH_ID}
+
+
+echo "I am running!!!!" >> log.txt
diff --git a/examples/worker1/worker1.cfg b/examples/worker1/worker1.cfg
index 0eabdf7..178723c 100644
--- a/examples/worker1/worker1.cfg
+++ b/examples/worker1/worker1.cfg
@@ -25,7 +25,7 @@ w_tags:
t_keyrings: ["allowed_users.asc"],
t_commands: [
{
- c_url: "file:///home/katolaz/bin/scorsh_build.sh"
+ c_url: "file:///home/katolaz/bin/scorsh_script.sh"
}
]
}
diff --git a/exec.go b/exec.go
index e2b22f1..f6a34ea 100644
--- a/exec.go
+++ b/exec.go
@@ -1,6 +1,7 @@
package main
import (
+ "bufio"
"fmt"
"log"
"net/url"
@@ -19,17 +20,15 @@ func exec_local_file(cmd_url *url.URL, args, env []string) error {
}
if err == nil {
- err = cmd.Start()
- if err == nil {
- var output []byte
- _, err := stdout.Read(output)
- if err != nil {
- log.Printf("[%s - stout follows: ]\n%s\n", output)
- err = cmd.Wait()
+ if err = cmd.Start(); err == nil {
+ buff := bufio.NewScanner(stdout)
+ log.Printf("[%s - stout follows: ]\n", cmd.Path)
+ for buff.Scan() {
+ log.Printf(buff.Text()) // write each line to your log, or anything you need
}
+ err = cmd.Wait()
}
}
-
return err
}
@@ -65,7 +64,7 @@ func set_environment(msg *SCORSHmsg) []string {
env = append(env, fmt.Sprintf("SCORSH_REPO=%s", msg.Repo))
env = append(env, fmt.Sprintf("SCORSH_BRANCH=%s", msg.Branch))
env = append(env, fmt.Sprintf("SCORSH_OLDREV=%s", msg.Old_rev))
- env = append(env, fmt.Sprintf("SCORSH_NEWREV_=%s", msg.New_rev))
- env = append(env, fmt.Sprintf("SCORSH_ID_=%s", msg.Id))
+ env = append(env, fmt.Sprintf("SCORSH_NEWREV=%s", msg.New_rev))
+ env = append(env, fmt.Sprintf("SCORSH_ID=%s", msg.Id))
return env
}