-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·94 lines (76 loc) · 2.67 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·94 lines (76 loc) · 2.67 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_SOURCE="${BASH_SOURCE[0]:-$0}"
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_SOURCE")" && pwd)"
LOCAL_INSTALLER="$SCRIPT_DIR/scripts/install-local.sh"
OPENBRIDGE_REPO="${OPENBRIDGE_REPO:-60ke/openBridge}"
OPENBRIDGE_REF="${OPENBRIDGE_REF:-master}"
OPENBRIDGE_INSTALL_ROOT="${OPENBRIDGE_INSTALL_ROOT:-$HOME/.openbridge}"
OPENBRIDGE_INSTALL_DIR="${OPENBRIDGE_INSTALL_DIR:-$OPENBRIDGE_INSTALL_ROOT/repo}"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'
info() { echo -e "${CYAN}==>${NC} $*"; }
ok() { echo -e "${GREEN} ✓${NC} $*"; }
warn() { echo -e "${YELLOW} ⚠${NC} $*"; }
fail() { echo -e "${RED} ✗${NC} $*"; }
usage() {
cat <<EOF
Usage:
./install.sh [options]
curl -fsSL https://raw.githubusercontent.com/${OPENBRIDGE_REPO}/${OPENBRIDGE_REF}/install.sh | bash
Options:
--no-skill Build and start OpenBridge, but skip skill installation
--no-start Build and install skill, but do not start the daemon
-h, --help Show this help
Environment:
OPENBRIDGE_REPO GitHub repo, default ${OPENBRIDGE_REPO}
OPENBRIDGE_REF Git ref to install, default ${OPENBRIDGE_REF}
OPENBRIDGE_INSTALL_ROOT Base install dir, default ${OPENBRIDGE_INSTALL_ROOT}
OPENBRIDGE_INSTALL_DIR Repo checkout dir, default ${OPENBRIDGE_INSTALL_DIR}
EOF
}
for arg in "$@"; do
case "$arg" in
-h|--help)
usage
exit 0
;;
esac
done
if [[ -f "$LOCAL_INSTALLER" && -d "$SCRIPT_DIR/packages" && -d "$SCRIPT_DIR/skills" ]]; then
exec bash "$LOCAL_INSTALLER" "$@"
fi
if ! command -v curl >/dev/null 2>&1; then
fail "curl is required for network installation"
exit 1
fi
if ! command -v tar >/dev/null 2>&1; then
fail "tar is required for network installation"
exit 1
fi
ARCHIVE_URL="https://github.com/${OPENBRIDGE_REPO}/archive/refs/heads/${OPENBRIDGE_REF}.tar.gz"
TMP_DIR="$(mktemp -d)"
ARCHIVE_PATH="$TMP_DIR/openbridge.tar.gz"
EXTRACT_DIR="$TMP_DIR/extract"
mkdir -p "$EXTRACT_DIR"
cleanup() {
rm -rf "$TMP_DIR"
}
trap cleanup EXIT
info "Downloading OpenBridge from ${ARCHIVE_URL}..."
curl -fsSL "$ARCHIVE_URL" -o "$ARCHIVE_PATH"
info "Extracting archive..."
tar -xzf "$ARCHIVE_PATH" -C "$EXTRACT_DIR"
SOURCE_DIR="$(find "$EXTRACT_DIR" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
if [[ -z "$SOURCE_DIR" || ! -f "$SOURCE_DIR/scripts/install-local.sh" ]]; then
fail "Downloaded archive does not contain a valid OpenBridge installer"
exit 1
fi
mkdir -p "$(dirname "$OPENBRIDGE_INSTALL_DIR")"
rm -rf "$OPENBRIDGE_INSTALL_DIR"
mv "$SOURCE_DIR" "$OPENBRIDGE_INSTALL_DIR"
ok "OpenBridge downloaded to $OPENBRIDGE_INSTALL_DIR"
exec bash "$OPENBRIDGE_INSTALL_DIR/scripts/install-local.sh" "$@"