-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_ground.bash
More file actions
executable file
·66 lines (58 loc) · 2.1 KB
/
start_ground.bash
File metadata and controls
executable file
·66 lines (58 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /bin/bash
# This script automatically chooses a ground station binary and config to run
# You may specify through cli arguments what config and binary should be ran
#
# Usage: ./start_ground.bash [config_path?] [binary_path?]
#
# The search order for config files is:
# 0. CLI argument 1
# 1. ./etc/config.toml
#
# The search order for binaries to use is:
# 0. CLI argument 2
# 1. ./target/deployed/ground
# 2. ./target/release/ground
# 3. ./target/debug/ground
#
# Search orders goes from lowest to highest. With the lowest ordered path(ie: 0)
# being searched first. Then proceeding on if the path do not exist.
set -e
SCRIPT_PATH="$(readlink -f "${BASH_SOURCE[0]}")"
SCRIPT_DIR="$(dirname -- "${SCRIPT_PATH}")"
cd "${SCRIPT_DIR}"
CONFIG="./etc/config.toml"
if [[ ! -z "$1" ]]; then
CONFIG="$1"
echo "[CLI] Using command line specified config at $CONFIG"
fi
if [[ ! -f "$CONFIG" ]]; then
echo "[CLI] No config found! Unable to start!"
exit 1
fi
TARGET=""
if [[ ! -z "$2" ]]; then
TARGET=$2
echo "[CLI] Using command line specified binary at $TARGET"
elif [[ -f "./target/deployed/release/ground" ]]; then
echo "[CLI] Deployed release ground build found! Using ./target/deployed/release/ground"
TARGET="./target/deployed/release/ground"
elif [[ -f "./target/deployed/debug/ground" ]]; then
echo "[CLI] Deployed debug ground build found! Using ./target/deployed/debug/ground"
TARGET="./target/deployed/debug/ground"
elif [[ -f "./target/release/ground" ]]; then
echo "[CLI] Local release ground build found! Using ./target/release/ground"
TARGET="./target/release/ground"
elif [[ -f "./target/debug/ground" ]]; then
echo "[CLI] Local debug ground build found! Using ./target/debug/ground"
TARGET="./target/debug/ground"
fi
if [[ ! -f "$TARGET" ]]; then
echo "[CLI] No compiled binaries found! Unable to start!"
exit 1
fi
echo "[CLI] Resetting LoRa gateway."
./reset_lgw.sh stop
echo "[CLI] Starting LoRa gateway."
./reset_lgw.sh start
echo "[CLI] Starting ground using binary at $TARGET and config at $CONFIG"
exec $TARGET "$CONFIG"