diff --git a/cmd/main.go b/cmd/main.go index ab44ac9..0aae156 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,9 +1,32 @@ package main import ( + "flag" + "fmt" + "github.com/jetkvm/kvm" + "github.com/prometheus/common/version" ) +func printVersion() { + version.Version = kvm.GetBuiltAppVersion() + app_version := version.Print("JetKVM Application") + fmt.Println(app_version) + + nativeVersion, err := kvm.GetNativeVersion() + if err == nil { + fmt.Println("\nJetKVM Native, version", nativeVersion) + } +} + func main() { + versionPtr := flag.Bool("version", false, "print version and exit") + flag.Parse() + + if *versionPtr { + printVersion() + return + } + kvm.Main() } diff --git a/dev_deploy.sh b/dev_deploy.sh index a2d32ed..90ced64 100755 --- a/dev_deploy.sh +++ b/dev_deploy.sh @@ -174,7 +174,7 @@ cd "${REMOTE_PATH}" chmod +x jetkvm_app_debug # Run the application in the background -PION_LOG_TRACE=${LOG_TRACE_SCOPES} ./jetkvm_app_debug +PION_LOG_TRACE=${LOG_TRACE_SCOPES} ./jetkvm_app_debug | tee -a /tmp/jetkvm_app_debug.log EOF echo "Deployment complete." \ No newline at end of file diff --git a/native.go b/native.go index 496f580..a285953 100644 --- a/native.go +++ b/native.go @@ -282,6 +282,22 @@ func shouldOverwrite(destPath string, srcHash []byte) bool { return !bytes.Equal(srcHash, dstHash) } +func getNativeSha256() ([]byte, error) { + version, err := resource.ResourceFS.ReadFile("jetkvm_native.sha256") + if err != nil { + return nil, err + } + return version, nil +} + +func GetNativeVersion() (string, error) { + version, err := getNativeSha256() + if err != nil { + return "", err + } + return string(version), nil +} + func ensureBinaryUpdated(destPath string) error { srcFile, err := resource.ResourceFS.Open("jetkvm_native") if err != nil { @@ -289,7 +305,7 @@ func ensureBinaryUpdated(destPath string) error { } defer srcFile.Close() - srcHash, err := resource.ResourceFS.ReadFile("jetkvm_native.sha256") + srcHash, err := getNativeSha256() if err != nil { nativeLogger.Debug().Msg("error reading embedded jetkvm_native.sha256, proceeding with update") srcHash = nil diff --git a/ota.go b/ota.go index cf97cc0..45603f0 100644 --- a/ota.go +++ b/ota.go @@ -50,6 +50,10 @@ const UpdateMetadataUrl = "https://api.jetkvm.com/releases" var builtAppVersion = "0.1.0+dev" +func GetBuiltAppVersion() string { + return builtAppVersion +} + func GetLocalVersion() (systemVersion *semver.Version, appVersion *semver.Version, err error) { appVersion, err = semver.NewVersion(builtAppVersion) if err != nil {