Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
36 lines (31 loc) · 1.46 KB
/
Copy pathinstall.sh
File metadata and controls
36 lines (31 loc) · 1.46 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
#!/usr/bin/env bash
set -Eeuo pipefail
REPO_URL="${MOTIONMODULE_REPO_URL:-https://github.com/AloeVeraZ/MotionModule.git}"
REF="${MOTIONMODULE_VERSION:-main}"
args=("$@")
for ((index = 0; index < ${#args[@]}; index++)); do
if [ "${args[$index]}" = "--version" ] && [ $((index + 1)) -lt ${#args[@]} ]; then
REF="${args[$((index + 1))]}"
fi
done
script_path="${BASH_SOURCE[0]:-}"
script_dir=""
if [ -n "$script_path" ]; then
script_dir="$(cd -- "$(dirname -- "$script_path")" 2>/dev/null && pwd || true)"
fi
if [ -n "$script_dir" ] && [ -f "$script_dir/installer/install.sh" ] && [ -f "$script_dir/pyproject.toml" ]; then
exec bash "$script_dir/installer/install.sh" --source "$script_dir" "$@"
fi
temporary="$(mktemp -d)"
cleanup() { rm -rf -- "$temporary"; }
trap cleanup EXIT
printf '\n[MotionModule] Downloading version %s...\n' "$REF"
if ! command -v git >/dev/null 2>&1; then
command -v sudo >/dev/null 2>&1 || { printf '[MotionModule ERROR] sudo is required to install Git.\n' >&2; exit 1; }
sudo env DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=60 update
sudo env DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=60 install -y git ca-certificates
fi
git clone --filter=blob:none --no-checkout "$REPO_URL" "$temporary/source"
git -C "$temporary/source" fetch --depth=1 origin "$REF"
git -C "$temporary/source" checkout --detach FETCH_HEAD
bash "$temporary/source/installer/install.sh" --source "$temporary/source" "$@"