|
|
|
|
@ -3,17 +3,18 @@ package main |
|
|
|
|
import ( |
|
|
|
|
"bytes" |
|
|
|
|
"encoding/json" |
|
|
|
|
"flag" |
|
|
|
|
"github.com/BurntSushi/toml" |
|
|
|
|
common "github.com/curusarn/resh/common" |
|
|
|
|
"io/ioutil" |
|
|
|
|
"log" |
|
|
|
|
"net/http" |
|
|
|
|
"os" |
|
|
|
|
"os/exec" |
|
|
|
|
"os/user" |
|
|
|
|
"path/filepath" |
|
|
|
|
"flag" |
|
|
|
|
"log" |
|
|
|
|
"net/http" |
|
|
|
|
"strconv" |
|
|
|
|
"strings" |
|
|
|
|
common "github.com/curusarn/resh/common" |
|
|
|
|
"github.com/BurntSushi/toml" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
|
@ -84,7 +85,6 @@ func main() { |
|
|
|
|
realtimeBeforeLocal := realtimeBefore + timezoneBeforeOffset |
|
|
|
|
realtimeAfterLocal := realtimeAfter + timezoneAfterOffset |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rec := common.Record{ |
|
|
|
|
// core
|
|
|
|
|
CmdLine: *cmdLine, |
|
|
|
|
@ -127,6 +127,7 @@ func main() { |
|
|
|
|
RealtimeSinceBoot: realtimeSinceBoot, |
|
|
|
|
|
|
|
|
|
GitWorkTree: getGitDir(), |
|
|
|
|
MachineId: getMachineId(), |
|
|
|
|
} |
|
|
|
|
sendRecord(rec, strconv.Itoa(config.Port)) |
|
|
|
|
} |
|
|
|
|
@ -151,6 +152,14 @@ func sendRecord(r common.Record, port string) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getMachineId() string { |
|
|
|
|
dat, err := ioutil.ReadFile("/etc/machine-id") |
|
|
|
|
if err != nil { |
|
|
|
|
log.Fatal("failed to open /etc/machine-id") |
|
|
|
|
} |
|
|
|
|
return string(dat) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getGitDir() string { |
|
|
|
|
// assume we are in pwd
|
|
|
|
|
gitWorkTree := os.Getenv("GIT_WORK_TREE") |
|
|
|
|
@ -189,4 +198,3 @@ func getTimezoneOffsetInSeconds(zone string) float64 { |
|
|
|
|
secs := ((hours * 60) + mins) * 60 |
|
|
|
|
return float64(secs) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|