-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathverify.sh
More file actions
executable file
·47 lines (35 loc) · 1.26 KB
/
Copy pathverify.sh
File metadata and controls
executable file
·47 lines (35 loc) · 1.26 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
#!/usr/bin/env bash
set -euo pipefail
REPO="Dicklesworthstone/system_resource_protection_script"
REF="${1:-main}" # branch, tag, or commit sha (default: main)
die() { echo "[verify] $*" >&2; exit 1; }
require() { command -v "$1" >/dev/null 2>&1 || die "Missing required tool: $1"; }
require curl
sha_cmd=""
if command -v sha256sum >/dev/null 2>&1; then
sha_cmd="sha256sum"
elif command -v shasum >/dev/null 2>&1; then
sha_cmd="shasum -a 256"
else
die "Missing required tool: sha256sum or shasum"
fi
CB="$(date +%s)" # cache-buster
BASE="https://raw.githubusercontent.com/${REPO}/${REF}"
echo "[verify] Using ref: $REF"
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
curl -fsSL "${BASE}/install.sh?cb=${CB}" -o "$tmp/install.sh" || die "Failed to download install.sh"
curl -fsSL "${BASE}/SHA256SUMS?cb=${CB}" -o "$tmp/SHA256SUMS" || die "Failed to download SHA256SUMS"
echo "[verify] Verifying checksum..."
(
cd "$tmp"
grep " install.sh$" SHA256SUMS > install.sha
$sha_cmd -c install.sha
)
echo "[verify] Checksum OK"
dest="${PWD}/install.sh"
cp "$tmp/install.sh" "$dest" || die "Failed to copy installer to $dest"
chmod +x "$dest" || true
echo "[verify] Wrote installer to: $dest"
echo "[verify] To run the installer:"
echo "$dest [--plan|--install|--uninstall]"