diff --git a/rootfs/rename_current_arch_binary.sh b/rootfs/rename_current_arch_binary.sh index 3259894..55a2785 100755 --- a/rootfs/rename_current_arch_binary.sh +++ b/rootfs/rename_current_arch_binary.sh @@ -5,7 +5,7 @@ set -x ls -la /opt/ # determine which binary to keep -if /opt/sdre-hub.amd64 --version; then +if /opt/sdre-hub.amd64 --version > /dev/null 2>&1; then mv -v /opt/sdre-hub.amd64 /opt/sdre-hub elif /opt/sdre-hub.arm64 --version > /dev/null 2>&1; then mv -v /opt/sdre-hub.arm64 /opt/sdre-hub diff --git a/src/bin/sdre-hub/src/main.rs b/src/bin/sdre-hub/src/main.rs index f45d44c..71523da 100644 --- a/src/bin/sdre-hub/src/main.rs +++ b/src/bin/sdre-hub/src/main.rs @@ -18,6 +18,16 @@ use std::error::Error; #[tokio::main] async fn main() -> Result<(), Box> { + // Check the command line args and see if `--version` was passed. + // If so, print version and exit 0 + + if std::env::args().any(|x| x == *"--version") { + // get the version from the Cargo.toml file + let version = env!("CARGO_PKG_VERSION"); + println!("SDRE Hub version: {version}"); + return Ok(()); + } + let config = ShConfig::new(); let hub = SdreHub::new(config);