From 3415e436badb76d0e06e3b51fdf89b6acec3f09f Mon Sep 17 00:00:00 2001 From: Markus Thielen Date: Thu, 20 Apr 2023 10:40:10 +0200 Subject: [PATCH] sh scripts run with bin dist and in source tree --- bbconf/broker.sh | 7 +++++-- bbconf/compile.sh | 6 ++++-- bbconf/dbproxy.sh | 7 +++++-- bbconf/util.sh | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 bbconf/util.sh diff --git a/bbconf/broker.sh b/bbconf/broker.sh index be0b5b2..b97f866 100755 --- a/bbconf/broker.sh +++ b/bbconf/broker.sh @@ -1,3 +1,6 @@ -#!/bin/sh +#!/bin/bash # Run basebox broker from the samples/toodo/bbconf directory -../../basebox/bin/broker -c broker-config.toml + +. ./util.sh + +bb_run broker -c broker-config.toml diff --git a/bbconf/compile.sh b/bbconf/compile.sh index d948faa..3fc8916 100755 --- a/bbconf/compile.sh +++ b/bbconf/compile.sh @@ -1,5 +1,7 @@ -#!/bin/sh +#!/bin/bash # # Compile the todo schema. # -../../baseboxbin/bbc --prefix=bb_todo -f todo_schema.graphql +. ./util.sh + +bb_run bbc --prefix=bb_todo -f todo_schema.graphql diff --git a/bbconf/dbproxy.sh b/bbconf/dbproxy.sh index 9bd79aa..ce282b8 100755 --- a/bbconf/dbproxy.sh +++ b/bbconf/dbproxy.sh @@ -1,3 +1,6 @@ -#!/bin/sh +#!/bin/bash # Run basebox dbproxy from the samples/toodo/bbconf directory -../../basebox/bin/dbproxy -c dbproxy-config.toml + +. ./util.sh + +bb_run dbproxy -c dbproxy-config.toml diff --git a/bbconf/util.sh b/bbconf/util.sh new file mode 100644 index 0000000..033c254 --- /dev/null +++ b/bbconf/util.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Utility functions for basebox test shell scripts +# + +bin_dir="../../basebox/bin" +source_dir="../../.." + +# +# Run a basebox command. +# +# Assuming that if run by a customer that wants to try the demo app, we first look if there +# is an exeutable at "../../basebox/bin/$1" and run it if present. +# If not, we assume this is being run inside of a basebox developer environment and start the +# command with "cargo run". +# +function bb_run { + command="$1" + args="${@:2}" + + # check bin directory + if [ -f "$bin_dir/$command" ]; then + "$bin_dir/$command" $args + return $? + fi + + # check source tree + if [ -d "$source_dir/$command" ]; then + cargo run --manifest-path=$source_dir/$command/Cargo.toml -- $args + return $? + fi + + echo "Program '$command' not found!" + return 2 +}