#!/bin/sh # lightmails Node-Installer # Quelltext vor dem Ausführen ansehen: https://lightmails.com/install.sh # # Nutzung: curl -fsSL https://lightmails.com/install.sh | sudo LIGHTMAIL_TOKEN= sh # Ohne LIGHTMAIL_TOKEN wird nur installiert; verbinden danach mit: # sudo -u lightmail lightmail node enroll set -eu BASE="${LIGHTMAIL_BASE:-https://lightmails.com}" BIN=/usr/local/bin/lightmail DATA=/var/lib/lightmail-node say() { printf '%s\n' "$*"; } die() { printf 'Fehler: %s\n' "$*" >&2; exit 1; } [ "$(id -u)" -eq 0 ] || die "Bitte als root ausführen (sudo)." [ "$(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 for c in curl sha256sum systemctl useradd install; do command -v "$c" >/dev/null 2>&1 || die "Das Programm '$c' wird benötigt." done tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT say "Lade lightmail ($ARCH) von $BASE ..." curl -fsSL "$BASE/download/lightmail-linux-$ARCH" -o "$tmp/lightmail" curl -fsSL "$BASE/download/lightmail-linux-$ARCH.sha256" -o "$tmp/lightmail.sha256" 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" id lightmail >/dev/null 2>&1 || useradd --system --home-dir "$DATA" --shell /usr/sbin/nologin lightmail install -d -m 0700 -o lightmail -g lightmail "$DATA" cat > /etc/systemd/system/lightmail-node.service </dev/null 2>&1; then runuser -u lightmail -- "$@"; else su -s /bin/sh lightmail -c "$*"; fi } if [ -n "${LIGHTMAIL_TOKEN:-}" ]; then say "Verbinde den Node mit $BASE ..." as_lightmail "$BIN" node --data "$DATA" enroll "$LIGHTMAIL_TOKEN" --server "$BASE" || die "Enrollment fehlgeschlagen. Ist das Token noch gültig (24 Stunden)?" systemctl enable --now lightmail-node say "" say "Fertig. Der Node läuft und holt Mails alle 30 Sekunden ab." say " Status: sudo -u lightmail lightmail node status" say " Postfach-Passwort: echo 'neues-passwort' | sudo -u lightmail lightmail node mailbox passwd name@deine-domain.de" say " Logs: journalctl -u lightmail-node -f" else say "" say "Installiert. Nächster Schritt: Node im Panel anlegen und mit dem Token verbinden:" say " sudo -u lightmail lightmail node enroll && sudo systemctl enable --now lightmail-node" fi