Browse Source

Add -version flag, bump to 2.2.8

Ask Bjørn Hansen 12 years ago
parent
commit
ca3c65f5d4
2 changed files with 15 additions and 2 deletions
  1. 4 1
      build
  2. 11 1
      geodns.go

+ 4 - 1
build

@@ -1,6 +1,9 @@
 #!/bin/sh
 #!/bin/sh
 #go get -v
 #go get -v
 REVISION=`git rev-parse --short=5  HEAD`
 REVISION=`git rev-parse --short=5  HEAD`
+BUILDTIME=`TZ=UTC date "+%Y-%m-%dT%H:%MZ"`
 echo $REVISION > REVISION
 echo $REVISION > REVISION
-go build -ldflags "-X main.gitVersion $REVISION" -v
+go build \
+  -ldflags "-X main.gitVersion $REVISION -X main.buildTime $BUILDTIME" \
+  -v && \
 go install
 go install

+ 11 - 1
geodns.go

@@ -18,6 +18,7 @@ package main
 
 
 import (
 import (
 	"flag"
 	"flag"
+	"fmt"
 	"log"
 	"log"
 	"net"
 	"net"
 	"os"
 	"os"
@@ -29,8 +30,10 @@ import (
 	"time"
 	"time"
 )
 )
 
 
-var VERSION string = "2.2.7"
+var VERSION string = "2.2.8"
+var buildTime string
 var gitVersion string
 var gitVersion string
+
 var serverId string
 var serverId string
 var serverIP string
 var serverIP string
 var serverGroups []string
 var serverGroups []string
@@ -47,6 +50,8 @@ var (
 	flaglog         = flag.Bool("log", false, "be more verbose")
 	flaglog         = flag.Bool("log", false, "be more verbose")
 	flagcpus        = flag.Int("cpus", 1, "Set the maximum number of CPUs to use")
 	flagcpus        = flag.Int("cpus", 1, "Set the maximum number of CPUs to use")
 
 
+	flagShowVersion = flag.Bool("version", false, "Show dnsconfig version")
+
 	cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
 	cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
 	memprofile = flag.String("memprofile", "", "write memory profile to this file")
 	memprofile = flag.String("memprofile", "", "write memory profile to this file")
 )
 )
@@ -63,6 +68,11 @@ func init() {
 func main() {
 func main() {
 	flag.Parse()
 	flag.Parse()
 
 
+	if *flagShowVersion {
+		fmt.Println("geodns", VERSION, buildTime)
+		os.Exit(0)
+	}
+
 	if len(*flagidentifier) > 0 {
 	if len(*flagidentifier) > 0 {
 		ids := strings.Split(*flagidentifier, ",")
 		ids := strings.Split(*flagidentifier, ",")
 		serverId = ids[0]
 		serverId = ids[0]