run-orly.sh raw
1 #!/bin/bash
2
3 # Universal run script for ORLY relay
4 # Automatically selects the correct binary for the current platform
5
6 set -e
7
8 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9 REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
10
11 # Source platform detection
12 source "$SCRIPT_DIR/platform-detect.sh"
13
14 # Get version
15 VERSION=$(cat "$REPO_ROOT/pkg/version/version")
16
17 # Detect platform
18 PLATFORM=$(detect_platform)
19 if [ $? -ne 0 ]; then
20 echo "Error: Could not detect platform"
21 exit 1
22 fi
23
24 echo "Detected platform: $PLATFORM"
25
26 # Get binary name
27 BINARY_NAME=$(get_binary_name "$VERSION")
28 BINARY_PATH="$REPO_ROOT/build/$BINARY_NAME"
29
30 # Check if binary exists
31 if [ ! -f "$BINARY_PATH" ]; then
32 echo "Error: Binary not found: $BINARY_PATH"
33 echo ""
34 echo "Please run: ./scripts/build-all-platforms.sh"
35 exit 1
36 fi
37
38 # Get library name and set library path
39 LIBRARY_NAME=$(get_library_name)
40 LIBRARY_PATH="$REPO_ROOT/build/$LIBRARY_NAME"
41
42 if [ -f "$LIBRARY_PATH" ]; then
43 case "$PLATFORM" in
44 linux-*)
45 export LD_LIBRARY_PATH="$REPO_ROOT/build:${LD_LIBRARY_PATH:-}"
46 ;;
47 darwin-*)
48 export DYLD_LIBRARY_PATH="$REPO_ROOT/build:${DYLD_LIBRARY_PATH:-}"
49 ;;
50 windows-*)
51 export PATH="$REPO_ROOT/build:${PATH:-}"
52 ;;
53 esac
54 echo "Library path set for: $LIBRARY_NAME"
55 else
56 echo "Warning: Library not found: $LIBRARY_PATH"
57 echo "Binary may not work if it requires libsecp256k1"
58 fi
59
60 echo "Running: $BINARY_NAME"
61 echo ""
62
63 # Execute the binary with all arguments passed to this script
64 exec "$BINARY_PATH" "$@"
65
66