#!/bin/sh # # shepta-frontend one-liner installer (POSIX sh; works with dash/bash) # # curl -fsSL /install.sh | sh # curl -fsSL /install.sh | sudo sh # sh install.sh # set -eu # --------------------------------------------------------------------------- # config # --------------------------------------------------------------------------- KEY_URL="https://36da79c3e961cdfbbf475ca203e5759ddc31589d@yena.dev/api/packages/Furrydelphia/debian/repository.key" KEYRING="/etc/apt/keyrings/forgejo-Furrydelphia.asc" LIST_FILE="/etc/apt/sources.list.d/forgejo.list" PACKAGE="shepta-frontend" COMPONENT="main" REPO_URL="$(dirname "$KEY_URL")" # .../Furrydelphia/debian # --------------------------------------------------------------------------- # pretty output (color only when stdout is a tty) # --------------------------------------------------------------------------- C_RED=""; C_GRN=""; C_YEL=""; C_BLU=""; C_BLD=""; C_DIM=""; C_RST="" if [ -t 1 ]; then ESC=$(printf '\033') C_RED="${ESC}[31m"; C_GRN="${ESC}[32m"; C_YEL="${ESC}[33m"; C_BLU="${ESC}[34m" C_BLD="${ESC}[1m"; C_DIM="${ESC}[2m"; C_RST="${ESC}[0m" fi log() { printf "%s==>%s %s\n" "$C_BLU" "$C_RST" "$*"; } ok() { printf " %s✓%s %s\n" "$C_GRN" "$C_RST" "$*"; } warn() { printf " %s!%s %s\n" "$C_YEL" "$C_RST" "$*" >&2; } die() { printf " %s✗%s %s\n" "$C_RED" "$C_RST" "$*" >&2; _FAILED=1; exit 1; } # friendly message on an unexpected (set -e) exit; skipped for explicit die() _FAILED=0 trap 'rc=$?; if [ "$rc" -ne 0 ] && [ "$_FAILED" -eq 0 ]; then printf " %s✗%s installer aborted (exit %s)\n" "$C_RED" "$C_RST" "$rc" >&2; fi' EXIT # --------------------------------------------------------------------------- # preflight checks # --------------------------------------------------------------------------- log "shepta-frontend installer" [ "$(id -u)" -eq 0 ] || warn "not running as root — sudo will be prompted per step." command -v apt-get >/dev/null 2>&1 || die "apt-get not found; this installer targets Debian/Ubuntu (Raspbian)." command -v curl >/dev/null 2>&1 || die "curl not found; please install it first." ARCH="$(dpkg --print-architecture 2>/dev/null)" || die "could not detect apt architecture." ok "detected architecture: ${C_BLD}${ARCH}${C_RST}" # --------------------------------------------------------------------------- # step 1 — add the repository signing key (atomic: never clobber a good key) # --------------------------------------------------------------------------- log "adding repository signing key" sudo install -d -m 0755 /etc/apt/keyrings sudo curl -fsSL "$KEY_URL" -o "$KEYRING.tmp" sudo chmod 0644 "$KEYRING.tmp" sudo mv "$KEYRING.tmp" "$KEYRING" ok "key written to ${C_DIM}${KEYRING}${C_RST}" # --------------------------------------------------------------------------- # step 2 — add the apt source (idempotent: overwrite, never duplicate) # --------------------------------------------------------------------------- log "adding apt source for ${PACKAGE}" LIST_LINE="deb [signed-by=${KEYRING}] ${REPO_URL} ${ARCH} ${COMPONENT}" echo "$LIST_LINE" | sudo tee "$LIST_FILE" >/dev/null ok "source written to ${C_DIM}${LIST_FILE}${C_RST}" # --------------------------------------------------------------------------- # step 3 — update package index # --------------------------------------------------------------------------- log "updating apt package index" sudo apt-get update -qq ok "package index updated" # --------------------------------------------------------------------------- # step 4 — install # --------------------------------------------------------------------------- log "installing ${C_BLD}${PACKAGE}${C_RST}" sudo apt-get install -y "$PACKAGE" ok "${PACKAGE} installed" # --------------------------------------------------------------------------- # summary # --------------------------------------------------------------------------- if command -v dpkg >/dev/null 2>&1; then VER="$(dpkg -s "$PACKAGE" 2>/dev/null | awk '/^Version:/ {print $2}')" if [ -n "$VER" ]; then ok "version ${C_BLD}${VER}${C_RST}"; fi fi printf "\n%sDone.%s shepta-frontend is installed.\n" "$C_GRN" "$C_RST"