72 lines
2.1 KiB
Go
72 lines
2.1 KiB
Go
package main
|
|
|
|
/*
|
|
This simply parses the command line arguments using the default golang
|
|
package called 'flag'. This can be used as a simple template to parse
|
|
command line arguments in other programs.
|
|
|
|
It puts everything in a 'config' Protobuf which I think is a good
|
|
wrapper around the 'flags' package and doesn't need a whole mess of
|
|
global variables
|
|
*/
|
|
|
|
import "log"
|
|
import "time"
|
|
import "runtime"
|
|
// import "os"
|
|
// import "os/user"
|
|
// import "flag"
|
|
// import "fmt"
|
|
// import "runtime/debug"
|
|
// import "io/ioutil"
|
|
// import "strings"
|
|
// import "reflect"
|
|
// import "bytes"
|
|
// import "sys"
|
|
|
|
// import "github.com/golang/protobuf/jsonpb"
|
|
// import pb "git.wit.com/wit/witProtobuf"
|
|
import "git.wit.com/wit/shell"
|
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
|
|
|
//
|
|
// This is what you call from main()
|
|
//
|
|
func update() {
|
|
version := shell.Run("cat VERSION")
|
|
|
|
mirrorsBUILDDATE := shell.Chomp(wget("https://mirrors.wit.com/cloud/control-panel/linux/BUILDDATE"))
|
|
upstream := shell.Chomp(wget("https://mirrors.wit.com/cloud/control-panel/linux/VERSION"))
|
|
upstreamEpoch := shell.Run("git log -1 --format=%at v" + upstream)
|
|
epoch := time.Now().Unix()
|
|
|
|
myBUILDDATE, _ := packrBox.FindString("BUILDDATE")
|
|
|
|
if (! config.Dirty) {
|
|
// See if a newer version of this control panel exists
|
|
// if (epoch > time.now().Unix()) // seconds since epoch
|
|
}
|
|
|
|
log.Println()
|
|
log.Println("version =", version)
|
|
log.Println("upstream =", upstream)
|
|
log.Println("now() =", epoch)
|
|
log.Println("myBUILDDATE =", myBUILDDATE)
|
|
log.Println("upstreamEpoch =", upstreamEpoch)
|
|
log.Println("mirrorsBUILDDATE =", mirrorsBUILDDATE)
|
|
log.Println()
|
|
log.Println("config.Gitref =", config.Gitref)
|
|
log.Println("config.Goversion =", config.Goversion)
|
|
log.Println("config.Dirty =", config.Dirty)
|
|
log.Println()
|
|
log.Println("runtime.Version =", runtime.Version())
|
|
log.Println("Number of CPUs =", runtime.NumCPU())
|
|
log.Println("Number of GoRoutines =", runtime.NumGoroutine())
|
|
log.Println("runtime.GOARCH =", runtime.GOARCH)
|
|
log.Println()
|
|
|
|
for {}
|
|
// os.Exit(0)
|
|
}
|