Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·73 lines (59 loc) · 1.9 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·73 lines (59 loc) · 1.9 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
#!/usr/bin/env bash
# plainapp installer
# Usage: curl -fsSL https://raw.githubusercontent.com/plainhub/plain-core/main/install.sh | bash
set -euo pipefail
REPO="plainhub/plain-core"
BIN="plainapp"
SERVICE="plainapp"
INSTALL_DIR="/usr/local/bin"
fail() {
echo "[plainapp] ERROR: $1" >&2
exit 1
}
fetch() {
if command -v curl &>/dev/null; then
curl -fsSL "$1"
elif command -v wget &>/dev/null; then
wget -qO- "$1"
else
fail "curl or wget is required"
fi
}
download() {
fetch "$1" >"$2" || fail "Failed to download $1"
}
case "$(uname -m)" in
x86_64 | amd64) ARCH="amd64" ;;
aarch64 | arm64) ARCH="arm64" ;;
*) fail "Unsupported architecture: $(uname -m). Only amd64 and arm64 are supported." ;;
esac
echo "[plainapp] Detecting platform... $ARCH"
TAG=$(
fetch "https://api.github.com/repos/${REPO}/releases/latest" |
grep '"tag_name"' |
sed 's/.*"tag_name": *"//' |
sed 's/".*//'
)
if [[ -z "$TAG" ]]; then
fail "Could not find a release. Is there a published release?"
fi
echo "[plainapp] Latest version: $TAG"
ASSET="${BIN}-linux-${ARCH}.tar.gz"
URL="https://github.com/${REPO}/releases/download/${TAG}/${ASSET}"
echo "[plainapp] Downloading $ASSET ..."
WORK=$(mktemp -d)
trap 'rm -rf "$WORK"' EXIT
download "$URL" "$WORK/$ASSET"
tar -xzf "$WORK/$ASSET" -C "$WORK" || fail "Failed to extract $ASSET."
sudo install -m 0755 "$WORK/$BIN" "$INSTALL_DIR/$BIN"
echo "[plainapp] Installed $BIN to $INSTALL_DIR."
sudo "$INSTALL_DIR/$BIN" install
sudo systemctl enable --now "$SERVICE"
IP=$(hostname -I 2>/dev/null | awk '{for (i=1;i<=NF;i++) if ($i!~/^127\./ && $i~/\./) {print $i; exit}}')
IP=${IP:-localhost}
echo ""
echo "[plainapp] Installation complete."
echo "[plainapp] Access the web UI:"
echo " http://$IP:8080"
echo " https://$IP:8443 (self-signed certificate)"
echo "[plainapp] Set the admin password with: sudo $BIN passwd"