-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·61 lines (55 loc) · 1.95 KB
/
bootstrap.sh
File metadata and controls
executable file
·61 lines (55 loc) · 1.95 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
#!/usr/bin/env bash
#
# NetWatch one-line bootstrap installer.
#
# Clones the repository (or pulls latest changes if already present), then
# runs install.sh. Designed to be safe to invoke via:
#
# curl -fsSL https://raw.githubusercontent.com/NoCoderRandom/netwatch/main/bootstrap.sh | bash
#
# Environment variables:
# INSTALL_DIR Where to clone the repo (default: $HOME/netwatch)
# BRANCH Branch to checkout (default: main)
# REPO Repository URL (default: NoCoderRandom/netwatch)
#
# Anything passed after `bash` is forwarded to install.sh — for example:
# curl ... | bash -s -- --symlink
set -euo pipefail
INSTALL_DIR="${INSTALL_DIR:-$HOME/netwatch}"
BRANCH="${BRANCH:-main}"
REPO="${REPO:-https://github.com/NoCoderRandom/netwatch.git}"
echo "==> NetWatch bootstrap"
echo " Repo: $REPO"
echo " Branch: $BRANCH"
echo " Target: $INSTALL_DIR"
echo
if ! command -v git >/dev/null 2>&1; then
cat >&2 <<'EOF'
git is not installed. Install it first:
Debian / Ubuntu / Pi OS: sudo apt install git
Fedora / RHEL: sudo dnf install git
Arch / Manjaro: sudo pacman -S git
openSUSE: sudo zypper install git
macOS: brew install git
EOF
exit 1
fi
if [ -d "$INSTALL_DIR/.git" ]; then
echo "==> $INSTALL_DIR already exists — pulling latest changes"
cd "$INSTALL_DIR"
git fetch --quiet origin "$BRANCH"
git checkout --quiet "$BRANCH"
git pull --ff-only --quiet origin "$BRANCH"
else
if [ -e "$INSTALL_DIR" ]; then
echo "Refusing to clone into $INSTALL_DIR — path exists but is not a git checkout." >&2
echo "Move it aside or set INSTALL_DIR=/some/other/path and re-run." >&2
exit 1
fi
echo "==> Cloning into $INSTALL_DIR"
git clone --quiet --branch "$BRANCH" --depth 1 "$REPO" "$INSTALL_DIR"
cd "$INSTALL_DIR"
fi
echo
echo "==> Running installer"
exec bash install.sh "$@"