forked from cbgbt/bottlerocket-forest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed-forest.sh
More file actions
executable file
·53 lines (44 loc) · 1.13 KB
/
seed-forest.sh
File metadata and controls
executable file
·53 lines (44 loc) · 1.13 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
#!/usr/bin/env bash
set -e
trap 'echo "❌ Error on line $LINENO. Command: $BASH_COMMAND" >&2' ERR
VERBOSE=false
if [ "$1" = "--verbose" ]; then
VERBOSE=true
fi
log() {
if [ "$VERBOSE" = true ]; then
echo "$@"
fi
}
get_workspace_version() {
local crate_name=$1
grep '^version = ' "crates/${crate_name}/Cargo.toml" | head -1 | cut -d'"' -f2
}
get_installed_version() {
local binary=$1
if command -v "$binary" &>/dev/null; then
"$binary" --version 2>/dev/null | awk '{print $2}'
else
echo ""
fi
}
install_if_needed() {
local binary=$1
local crate_name=$2
local workspace_version=$(get_workspace_version "$crate_name")
local installed_version=$(get_installed_version "$binary")
cargo install --path "crates/${crate_name}"
log "✓ $binary installed"
}
# Install forest tools first
log "Checking forest tools..."
install_if_needed "crumbly" "crumbly-cli"
install_if_needed "forester" "forester"
install_if_needed "brdev" "brdev"
# Use forester to seed the forest
if [ "$VERBOSE" = true ]; then
forester seed --verbose
else
forester seed
fi
log "✅ Setup complete"