chore: move to GitLab - server-install.sh takes the latest release and dist/ from gitlab.com/itzRedTea/lpra, README links and screenshots kept in the repo; a guide for moving other projects

This commit is contained in:
redtea committed 2026-10-18 10:44:18 +03:00
1 parent 173f46a145
commit 57de7bf967
7 files changed
+167 -19

No files matched your search

+16 -12
View File
@@ -1,9 +1,9 @@
#!/bin/sh
# LPRA server: install or update in one command.
#
# wget -qO- https://raw.githubusercontent.com/iRedTea/lpra/main/server-install.sh | sudo sh
# wget -qO- https://gitlab.com/itzRedTea/lpra/-/raw/main/server-install.sh | sudo sh
#
# Takes the server binary for this machine from the latest GitHub release and
# Takes the server binary for this machine from the latest GitLab release and
# the agent binaries (dist/) from the main branch, puts them in /opt/lpra,
# sets up the systemd service and, if asked, nginx with a domain and a
# certificate from certbot. Run again to update: the binary and dist/ are
@@ -16,7 +16,10 @@
# and where to.
set -eu
REPO=${LPRA_REPO:-iRedTea/lpra}
REPO=${LPRA_REPO:-itzRedTea/lpra}
GL=https://gitlab.com
# The project in the API's paths: its path with "/" as %2F.
API="$GL/api/v4/projects/$(printf '%s' "$REPO" | sed 's|/|%2F|g')"
DIR=${LPRA_DIR:-/opt/lpra}
SERVICE=lpra-server
UNIT=/etc/systemd/system/$SERVICE.service
@@ -75,14 +78,14 @@ confirm() {
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT INT TERM
TAG=$(fetch "https://api.github.com/repos/$REPO/releases/latest" 2>/dev/null |
TAG=$(fetch "$API/releases/permalink/latest" 2>/dev/null | tr ',' '\n' |
sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -n 1) || TAG=
if [ -n "$TAG" ]; then
say "последний релиз: $TAG"
BIN_URL="https://github.com/$REPO/releases/download/$TAG/lpra-server-linux-$ARCH"
BIN_URL="$GL/$REPO/-/releases/$TAG/downloads/lpra-server-linux-$ARCH"
else
warn "не узнать номер релиза у GitHub API - беру latest"
BIN_URL="https://github.com/$REPO/releases/latest/download/lpra-server-linux-$ARCH"
warn "не узнать номер релиза у GitLab API - беру latest"
BIN_URL="$GL/$REPO/-/releases/permalink/latest/downloads/lpra-server-linux-$ARCH"
fi
say "скачиваю сервер (linux/$ARCH)"
dl "$BIN_URL" "$TMP/lpra-server" || die "не скачался $BIN_URL"
@@ -90,12 +93,13 @@ chmod +x "$TMP/lpra-server"
say "скачиваю dist/ из ветки main"
mkdir -p "$TMP/dist"
URLS=$(fetch "https://api.github.com/repos/$REPO/contents/dist?ref=main" 2>/dev/null |
sed -n 's/.*"download_url": *"\([^"]*\)".*/\1/p') || URLS=
# The files of dist/ on main, by the API's list of the folder.
URLS=$(fetch "$API/repository/tree?path=dist&ref=main&per_page=100" 2>/dev/null | tr '{},' '\n\n\n' |
sed -n 's|^"path": *"\(dist/[^"]*\)"$|'"$GL/$REPO"'/-/raw/main/\1|p') || URLS=
if [ -z "$URLS" ]; then
warn "не получить список dist/ у GitHub API - беру агентов linux amd64 и arm64"
URLS="https://raw.githubusercontent.com/$REPO/main/dist/agent-linux-amd64
https://raw.githubusercontent.com/$REPO/main/dist/agent-linux-arm64"
warn "не получить список dist/ у GitLab API - беру агентов linux amd64 и arm64"
URLS="$GL/$REPO/-/raw/main/dist/agent-linux-amd64
$GL/$REPO/-/raw/main/dist/agent-linux-arm64"
fi
for u in $URLS; do
f=${u##*/}