зеркало из https://github.com/mozilla/mig.git
[minor] Add base Version in MIG package, overrided by Makefile
This commit is contained in:
Родитель
1e8f9f741c
Коммит
76f33f2dea
2
Makefile
2
Makefile
|
@ -37,7 +37,7 @@ LDFLAGS :=
|
|||
GOOPTS :=
|
||||
GO := GOOS=$(OS) GOARCH=$(ARCH) GO15VENDOREXPERIMENT=1 go
|
||||
GOGETTER := GOPATH=$(shell pwd)/.tmpdeps go get -d
|
||||
GOLDFLAGS := -ldflags "-X main.version=$(BUILDREV)"
|
||||
GOLDFLAGS := -ldflags "-X mig.ninja/mig.Version=$(BUILDREV)"
|
||||
GOCFLAGS :=
|
||||
MKDIR := mkdir
|
||||
INSTALL := install
|
||||
|
|
|
@ -10,15 +10,13 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"mig.ninja/mig"
|
||||
"mig.ninja/mig/client"
|
||||
"net/url"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// build version
|
||||
var version string
|
||||
"mig.ninja/mig"
|
||||
"mig.ninja/mig/client"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
|
@ -52,7 +50,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
if *showversion {
|
||||
fmt.Println(version)
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
@ -65,7 +63,7 @@ func main() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cli, err := client.NewClient(conf, "generator-"+version)
|
||||
cli, err := client.NewClient(conf, "generator-"+mig.Version)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -8,9 +8,10 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"mig.ninja/mig"
|
||||
"mig.ninja/mig/client"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -33,8 +34,14 @@ func main() {
|
|||
var actionfile = flag.String("a", "/path/to/action", "Load action from file")
|
||||
var commandfile = flag.String("c", "/path/to/command", "Load command from file")
|
||||
var config = flag.String("conf", homedir+"/.migrc", "Load configuration from file")
|
||||
var showversion = flag.Bool("V", false, "Show build version and exit")
|
||||
flag.Parse()
|
||||
|
||||
if *showversion {
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
conf, err := client.ReadConfiguration(*config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -22,9 +22,6 @@ import (
|
|||
"mig.ninja/mig/client"
|
||||
)
|
||||
|
||||
// build version
|
||||
var version string
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
defer func() {
|
||||
|
@ -41,7 +38,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
if *showversion {
|
||||
fmt.Println(version)
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
@ -74,7 +71,7 @@ func main() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cli, err := client.NewClient(conf, "console-"+version)
|
||||
cli, err := client.NewClient(conf, "console-"+mig.Version)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -19,9 +19,6 @@ import (
|
|||
"mig.ninja/mig/modules"
|
||||
)
|
||||
|
||||
// build version
|
||||
var version string
|
||||
|
||||
func usage() {
|
||||
fmt.Printf(`%s - Mozilla InvestiGator command line client
|
||||
usage: %s <module> <global options> <module parameters>
|
||||
|
@ -49,6 +46,7 @@ usage: %s <module> <global options> <module parameters>
|
|||
* agents operated by IT: -t "tags#>>'{operator}'='IT'"
|
||||
* run on local system: -t local
|
||||
-v verbose output, includes debug information and raw queries
|
||||
-V print version
|
||||
|
||||
Progress information is sent to stderr, silence it with "2>/dev/null".
|
||||
Results are sent to stdout, redirect them with "1>/path/to/file".
|
||||
|
@ -77,7 +75,7 @@ func main() {
|
|||
a mig.Action
|
||||
migrc, show, render, target, expiration, afile string
|
||||
printAndExit bool
|
||||
verbose bool
|
||||
verbose, showversion bool
|
||||
modargs []string
|
||||
run interface{}
|
||||
)
|
||||
|
@ -97,6 +95,7 @@ func main() {
|
|||
fs.StringVar(&expiration, "e", "300s", "expiration")
|
||||
fs.StringVar(&afile, "i", "/path/to/file", "Load action from file")
|
||||
fs.BoolVar(&verbose, "v", false, "Enable verbose output")
|
||||
fs.BoolVar(&showversion, "V", false, "Show version")
|
||||
|
||||
// if first argument is missing, or is help, print help
|
||||
// otherwise, pass the remainder of the arguments to the module for parsing
|
||||
|
@ -105,8 +104,8 @@ func main() {
|
|||
usage()
|
||||
}
|
||||
|
||||
if len(os.Args) < 2 || os.Args[1] == "-V" {
|
||||
fmt.Println(version)
|
||||
if showversion || (len(os.Args) > 1 && (os.Args[1] == "-V" || os.Args[1] == "version")) {
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
@ -234,7 +233,7 @@ readytolaunch:
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cli, err = client.NewClient(conf, "cmd-"+version)
|
||||
cli, err = client.NewClient(conf, "cmd-"+mig.Version)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -10,21 +10,19 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/jvehent/service-go"
|
||||
"github.com/streadway/amqp"
|
||||
"io/ioutil"
|
||||
"mig.ninja/mig"
|
||||
"mig.ninja/mig/modules"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// build version
|
||||
var version string
|
||||
"github.com/jvehent/service-go"
|
||||
"github.com/streadway/amqp"
|
||||
"mig.ninja/mig"
|
||||
"mig.ninja/mig/modules"
|
||||
)
|
||||
|
||||
// publication lock is used to prevent publication when the channels are not
|
||||
// available, like during a shutdown
|
||||
|
@ -73,7 +71,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
if *showversion {
|
||||
fmt.Println(version)
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
@ -205,7 +203,7 @@ func runAgentCheckin(foreground, upgrading, debug bool) (err error) {
|
|||
fmt.Fprintf(os.Stderr, "Failed to start agent routines: '%v'", err)
|
||||
os.Exit(0)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{Desc: fmt.Sprintf("Mozilla InvestiGator version %s: started agent %s in checkin mode", version, ctx.Agent.Hostname)}
|
||||
ctx.Channels.Log <- mig.Log{Desc: fmt.Sprintf("Mozilla InvestiGator version %s: started agent %s in checkin mode", mig.Version, ctx.Agent.Hostname)}
|
||||
|
||||
// The loop below retrieves messages from the relay. If no message is available,
|
||||
// it will timeout and break out of the loop after 10 seconds, causing the agent to exit
|
||||
|
@ -279,7 +277,7 @@ func runAgent(foreground, upgrading, debug bool) (err error) {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
ctx.Channels.Log <- mig.Log{Desc: fmt.Sprintf("Mozilla InvestiGator version %s: started agent %s", version, ctx.Agent.Hostname)}
|
||||
ctx.Channels.Log <- mig.Log{Desc: fmt.Sprintf("Mozilla InvestiGator version %s: started agent %s", mig.Version, ctx.Agent.Hostname)}
|
||||
|
||||
// The agent blocks here until a termination order is received
|
||||
// The order is then evaluated to decide if a new agent must be respawned, or the agent
|
||||
|
@ -669,7 +667,7 @@ func heartbeat(ctx Context) (err error) {
|
|||
HeartBeat := mig.Agent{
|
||||
Name: ctx.Agent.Hostname,
|
||||
Mode: ctx.Agent.Mode,
|
||||
Version: version,
|
||||
Version: mig.Version,
|
||||
PID: os.Getpid(),
|
||||
QueueLoc: ctx.Agent.QueueLoc,
|
||||
StartTime: time.Now(),
|
||||
|
|
|
@ -8,18 +8,16 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/gorilla/context"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/jvehent/cljs"
|
||||
"mig.ninja/mig"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// build version
|
||||
var version string
|
||||
"github.com/gorilla/context"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/jvehent/cljs"
|
||||
"mig.ninja/mig"
|
||||
)
|
||||
|
||||
var ctx Context
|
||||
|
||||
|
@ -35,7 +33,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
if *showversion {
|
||||
fmt.Println(version)
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,13 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"mig.ninja/mig"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"mig.ninja/mig"
|
||||
)
|
||||
|
||||
var ctx Context
|
||||
|
@ -24,8 +25,14 @@ func main() {
|
|||
var err error
|
||||
|
||||
var config = flag.String("c", "/etc/mig/runner.cfg", "Load configuration from file")
|
||||
var showversion = flag.Bool("V", false, "Show build version and exit")
|
||||
flag.Parse()
|
||||
|
||||
if *showversion {
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
ctx, err = initContext(*config)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
|
|
|
@ -19,17 +19,20 @@ import (
|
|||
"mig.ninja/mig/pgp"
|
||||
)
|
||||
|
||||
// build version
|
||||
var version string
|
||||
|
||||
func main() {
|
||||
cpus := runtime.NumCPU()
|
||||
runtime.GOMAXPROCS(cpus * 2)
|
||||
|
||||
// command line options
|
||||
var config = flag.String("c", "/etc/mig/scheduler.cfg", "Load configuration from file")
|
||||
var showversion = flag.Bool("V", false, "Show build version and exit")
|
||||
flag.Parse()
|
||||
|
||||
if *showversion {
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// The context initialization takes care of parsing the configuration,
|
||||
// and creating connections to database, message broker, syslog, ...
|
||||
fmt.Fprintf(os.Stderr, "Initializing Scheduler context...")
|
||||
|
|
|
@ -83,7 +83,7 @@ Module documentation is at http://mig.mozilla.org/doc/module_file.html
|
|||
Cheatsheet and examples are at http://mig.mozilla.org/doc/cheatsheet.rst.html
|
||||
`, dash, dash, dash, dash, dash, dash, dash, dash, dash, dash, dash,
|
||||
dash, dash, dash, dash, dash, dash, dash, dash, dash,
|
||||
dash, dash, dash, dash, dash, dash, dash, dash)
|
||||
dash, dash, dash, dash, dash, dash)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
// Contributor: Julien Vehent jvehent@mozilla.com [:ulfr]
|
||||
|
||||
package mig /* import "mig.ninja/mig" */
|
||||
|
||||
var Version string = "20150924+637dcd7"
|
|
@ -6,16 +6,17 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"gopkg.in/gcfg.v1"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/jvehent/gozdef"
|
||||
"mig.ninja/mig"
|
||||
"mig.ninja/mig/workers"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
|
||||
"github.com/jvehent/gozdef"
|
||||
"gopkg.in/gcfg.v1"
|
||||
"mig.ninja/mig"
|
||||
"mig.ninja/mig/workers"
|
||||
)
|
||||
|
||||
const workerName = "agent_intel"
|
||||
|
@ -42,7 +43,12 @@ func main() {
|
|||
flag.PrintDefaults()
|
||||
}
|
||||
var configPath = flag.String("c", "/etc/mig/agent-intel-worker.cfg", "Load configuration from file")
|
||||
var showversion = flag.Bool("V", false, "Show build version and exit")
|
||||
flag.Parse()
|
||||
if *showversion {
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
err = gcfg.ReadFileInto(&conf, *configPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"gopkg.in/gcfg.v1"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"gopkg.in/gcfg.v1"
|
||||
"mig.ninja/mig"
|
||||
"mig.ninja/mig/workers"
|
||||
"os"
|
||||
)
|
||||
|
||||
const workerName = "agent_verif"
|
||||
|
@ -31,7 +32,13 @@ func main() {
|
|||
flag.PrintDefaults()
|
||||
}
|
||||
var configPath = flag.String("c", "/etc/mig/agent-verif-worker.cfg", "Load configuration from file")
|
||||
var showversion = flag.Bool("V", false, "Show build version and exit")
|
||||
flag.Parse()
|
||||
if *showversion {
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
err = gcfg.ReadFileInto(&conf, *configPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -6,19 +6,20 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"gopkg.in/gcfg.v1"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/jvehent/gozdef"
|
||||
"mig.ninja/mig"
|
||||
"mig.ninja/mig/modules"
|
||||
"mig.ninja/mig/modules/file"
|
||||
"mig.ninja/mig/workers"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/jvehent/gozdef"
|
||||
"gopkg.in/gcfg.v1"
|
||||
"mig.ninja/mig"
|
||||
"mig.ninja/mig/modules"
|
||||
"mig.ninja/mig/modules/file"
|
||||
"mig.ninja/mig/workers"
|
||||
)
|
||||
|
||||
const workerName = "compliance_item"
|
||||
|
@ -46,7 +47,13 @@ func main() {
|
|||
flag.PrintDefaults()
|
||||
}
|
||||
var configPath = flag.String("c", "/etc/mig/compliance-item-worker.cfg", "Load configuration from file")
|
||||
var showversion = flag.Bool("V", false, "Show build version and exit")
|
||||
flag.Parse()
|
||||
if *showversion {
|
||||
fmt.Println(mig.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
err = gcfg.ReadFileInto(&conf, *configPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
Загрузка…
Ссылка в новой задаче