Release v1.0 – PiCopy vollständig dokumentiert und bereit zur Veröffentlichung
- README.md mit vollständiger Anleitung, Features, Tabellen und Schnellstart - install.sh neu geschrieben: sauberer Installer mit Farbausgabe, apt-Check, Download-Fallback und abschließender Statusmeldung mit URL - LICENSE (MIT) hinzugefügt - .gitignore: config.json, state.json, rclone.conf, logs/ und deploy.sh excluded - deploy.sh entfernt (enthielt Zugangsdaten) - requirements.txt aktualisiert Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
143
install.sh
143
install.sh
@@ -1,42 +1,111 @@
|
||||
#!/bin/bash
|
||||
# PiCopy Installations-Script für den Raspberry Pi
|
||||
# Ausführen auf dem Pi als root oder mit sudo:
|
||||
# sudo bash install.sh
|
||||
#!/usr/bin/env bash
|
||||
# ============================================================
|
||||
# PiCopy – Installer
|
||||
# https://github.com/YOUR_USERNAME/picopy
|
||||
#
|
||||
# Usage:
|
||||
# sudo bash install.sh
|
||||
# or one-line:
|
||||
# curl -sSL https://raw.githubusercontent.com/YOUR_USERNAME/picopy/main/install.sh | sudo bash
|
||||
# ============================================================
|
||||
set -euo pipefail
|
||||
|
||||
set -e
|
||||
INSTALL_DIR="/opt/picopy"
|
||||
SERVICE_NAME="picopy"
|
||||
PORT=8080
|
||||
REPO_RAW="https://raw.githubusercontent.com/YOUR_USERNAME/picopy/main"
|
||||
|
||||
PI_DIR="/opt/picopy"
|
||||
SERVICE="picopy"
|
||||
# ── Farben ───────────────────────────────────────────────────────────────────
|
||||
R='\033[0;31m'; G='\033[0;32m'; Y='\033[1;33m'; B='\033[0;34m'; N='\033[0m'
|
||||
info() { echo -e "${B}[PiCopy]${N} $1"; }
|
||||
ok() { echo -e "${G}[ OK ]${N} $1"; }
|
||||
warn() { echo -e "${Y}[ WARN ]${N} $1"; }
|
||||
fail() { echo -e "${R}[ FAIL ]${N} $1"; exit 1; }
|
||||
|
||||
echo "=== PiCopy Installation ==="
|
||||
|
||||
# Abhängigkeiten installieren
|
||||
echo ">> Pakete installieren..."
|
||||
apt-get update -q
|
||||
apt-get install -y python3 python3-venv python3-pip lsblk
|
||||
|
||||
# Verzeichnis anlegen
|
||||
echo ">> Verzeichnis anlegen: $PI_DIR"
|
||||
mkdir -p "$PI_DIR/logs"
|
||||
|
||||
# Python-Umgebung
|
||||
echo ">> Python venv erstellen..."
|
||||
python3 -m venv "$PI_DIR/venv"
|
||||
"$PI_DIR/venv/bin/pip" install --quiet flask pyudev
|
||||
|
||||
# App-Dateien kopieren
|
||||
echo ">> Dateien kopieren..."
|
||||
cp app.py "$PI_DIR/app.py"
|
||||
|
||||
# Systemd-Service einrichten
|
||||
echo ">> Systemd-Service einrichten..."
|
||||
cp picopy.service "/etc/systemd/system/$SERVICE.service"
|
||||
systemctl daemon-reload
|
||||
systemctl enable "$SERVICE"
|
||||
systemctl restart "$SERVICE"
|
||||
# ── Voraussetzungen ───────────────────────────────────────────────────────────
|
||||
[ "$EUID" -eq 0 ] || fail "Bitte als root ausführen: sudo bash install.sh"
|
||||
command -v apt-get &>/dev/null || fail "apt-get nicht gefunden (nur Debian/Raspberry Pi OS unterstützt)"
|
||||
|
||||
echo ""
|
||||
echo "=== Installation abgeschlossen ==="
|
||||
echo "Web-Interface: http://$(hostname -I | awk '{print $1}'):8080"
|
||||
echo "Status: systemctl status $SERVICE"
|
||||
echo "Logs: journalctl -u $SERVICE -f"
|
||||
echo -e "${B}╔══════════════════════════════════════════╗${N}"
|
||||
echo -e "${B}║ PiCopy – Installation ║${N}"
|
||||
echo -e "${B}╚══════════════════════════════════════════╝${N}"
|
||||
echo ""
|
||||
|
||||
# ── System-Pakete ─────────────────────────────────────────────────────────────
|
||||
info "Systemabhängigkeiten werden installiert..."
|
||||
apt-get update -q
|
||||
apt-get install -y -q python3 python3-venv python3-pip util-linux rclone
|
||||
ok "Systemabhängigkeiten installiert"
|
||||
|
||||
# ── Verzeichnis anlegen ───────────────────────────────────────────────────────
|
||||
info "Installationsverzeichnis: $INSTALL_DIR"
|
||||
mkdir -p "$INSTALL_DIR/logs"
|
||||
|
||||
# ── App-Datei kopieren oder herunterladen ─────────────────────────────────────
|
||||
if [ -f "./app.py" ]; then
|
||||
info "Lokale app.py wird verwendet..."
|
||||
cp app.py "$INSTALL_DIR/app.py"
|
||||
else
|
||||
info "app.py wird heruntergeladen..."
|
||||
curl -sSfL "$REPO_RAW/app.py" -o "$INSTALL_DIR/app.py" \
|
||||
|| fail "Download fehlgeschlagen. Prüfe die Internet-Verbindung."
|
||||
fi
|
||||
ok "app.py installiert"
|
||||
|
||||
# ── Python-Umgebung ───────────────────────────────────────────────────────────
|
||||
info "Python venv wird erstellt..."
|
||||
python3 -m venv "$INSTALL_DIR/venv"
|
||||
"$INSTALL_DIR/venv/bin/pip" install --quiet --upgrade pip
|
||||
"$INSTALL_DIR/venv/bin/pip" install --quiet flask pyudev
|
||||
ok "Python-Umgebung erstellt"
|
||||
|
||||
# ── Systemd-Service ───────────────────────────────────────────────────────────
|
||||
info "Systemd-Service wird eingerichtet..."
|
||||
|
||||
if [ -f "./picopy.service" ]; then
|
||||
cp picopy.service /etc/systemd/system/picopy.service
|
||||
else
|
||||
cat > /etc/systemd/system/picopy.service << 'EOF'
|
||||
[Unit]
|
||||
Description=PiCopy – Automatischer USB-Kopierdienst
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/picopy
|
||||
ExecStart=/opt/picopy/venv/bin/python /opt/picopy/app.py
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
fi
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable "$SERVICE_NAME"
|
||||
systemctl restart "$SERVICE_NAME"
|
||||
|
||||
# ── Ergebnis ─────────────────────────────────────────────────────────────────
|
||||
sleep 3
|
||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
IP=$(hostname -I | awk '{print $1}')
|
||||
echo ""
|
||||
echo -e "${G}╔══════════════════════════════════════════╗${N}"
|
||||
echo -e "${G}║ PiCopy ist bereit! ║${N}"
|
||||
echo -e "${G}╚══════════════════════════════════════════╝${N}"
|
||||
echo ""
|
||||
echo -e " Web-Interface: ${B}http://$IP:$PORT${N}"
|
||||
echo ""
|
||||
echo " Nützliche Befehle:"
|
||||
echo " sudo systemctl status $SERVICE_NAME # Status"
|
||||
echo " journalctl -u $SERVICE_NAME -f # Live-Logs"
|
||||
echo " sudo systemctl restart $SERVICE_NAME # Neustart"
|
||||
echo ""
|
||||
else
|
||||
fail "PiCopy konnte nicht gestartet werden."$'\n'"Logs: journalctl -u $SERVICE_NAME -n 50"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user