#!/bin/sh # lightmails CLI-Installer für KI-Agenten # Quelltext vor dem Ausführen ansehen: https://lightmails.com/cli-install.sh # # Aufruf: curl -fsSL https://lightmails.com/cli-install.sh | sh -s -- [https://lightmails.com] # # Der Token stammt aus dem Panel (Postfach-Einstellungen, "CLI für KI-Agenten"), ist # 10 Minuten gültig und nur einmal verwendbar. Das Skript lädt das lightmail-Binary # (SHA-256 geprüft), legt das CLI-Profil an und gibt weder Passwort noch Passphrase aus. set -eu TOKEN="${1:-}" BASE="${2:-https://lightmails.com}" say() { printf '%s\n' "$*"; } die() { printf 'Fehler: %s\n' "$*" >&2; exit 1; } [ -n "$TOKEN" ] || die "Aufruf: curl -fsSL $BASE/cli-install.sh | sh -s -- $BASE" [ "$(uname -s)" = "Linux" ] || die "Nur Linux wird unterstützt." case "$(uname -m)" in x86_64|amd64) ARCH=x86_64 ;; *) die "Die Architektur $(uname -m) wird noch nicht unterstützt (derzeit nur x86_64)." ;; esac command -v curl >/dev/null 2>&1 || die "Das Programm 'curl' wird benötigt." # Vorhandenes Binary nutzen, wenn es die Mail-CLI schon kennt; sonst nach ~/.local/bin installieren. BIN="$(command -v lightmail 2>/dev/null || true)" if [ -z "$BIN" ] || ! "$BIN" mail setup-token --help >/dev/null 2>&1; then DIR="${XDG_BIN_HOME:-$HOME/.local/bin}" BIN="$DIR/lightmail" mkdir -p "$DIR" tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT say "Lade lightmail ($ARCH) von $BASE ..." curl -fsSL "$BASE/download/lightmail-linux-$ARCH" -o "$tmp/lightmail" || die "Download fehlgeschlagen." curl -fsSL "$BASE/download/lightmail-linux-$ARCH.sha256" -o "$tmp/lightmail.sha256" || die "Prüfsumme nicht abrufbar." want="$(cut -d' ' -f1 "$tmp/lightmail.sha256")" have="$(sha256sum "$tmp/lightmail" | cut -d' ' -f1)" [ -n "$want" ] && [ "$want" = "$have" ] || die "Die Prüfsumme stimmt nicht überein. Abbruch." install -m 0755 "$tmp/lightmail" "$BIN" 2>/dev/null || { cp "$tmp/lightmail" "$BIN" && chmod 0755 "$BIN"; } case ":$PATH:" in *":$DIR:"*) ;; *) say "Hinweis: $DIR liegt nicht im PATH. Aufruf: $BIN mail ..." ;; esac fi # Weitere Argumente werden an setup-token durchgereicht (z. B. --tls-ca, --imap-port). shift 2 2>/dev/null || shift $# "$BIN" mail setup-token "$TOKEN" --server "$BASE" "$@"