Refactor code structure for improved readability and maintainability
This commit is contained in:
78
install.sh
78
install.sh
@@ -39,43 +39,65 @@ apt-get install -y -q python3 python3-venv python3-pip util-linux rclone \
|
||||
exfatprogs dosfstools ntfs-3g
|
||||
ok "Systemabhängigkeiten installiert"
|
||||
|
||||
# ── Verzeichnis anlegen ───────────────────────────────────────────────────────
|
||||
# ── Verzeichnisse anlegen ─────────────────────────────────────────────────────
|
||||
info "Installationsverzeichnis: $INSTALL_DIR"
|
||||
mkdir -p "$INSTALL_DIR/logs"
|
||||
mkdir -p "$INSTALL_DIR/picopy"
|
||||
mkdir -p "$INSTALL_DIR/routes"
|
||||
mkdir -p "$INSTALL_DIR/templates"
|
||||
|
||||
# ── 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
|
||||
# ── Hilfsfunktion: Datei kopieren oder herunterladen ──────────────────────────
|
||||
install_file() {
|
||||
local src="$1" # relativer Pfad im Repo / im lokalen Verzeichnis
|
||||
local dst="$2" # absoluter Zielpfad
|
||||
|
||||
if [ -f "./$src" ]; then
|
||||
info "Lokale Datei wird verwendet: $src"
|
||||
cp "./$src" "$dst"
|
||||
else
|
||||
info "Datei wird heruntergeladen: $src"
|
||||
curl -sSfL "$REPO_RAW/$src" -o "$dst" \
|
||||
|| warn "Download fehlgeschlagen: $src (nicht kritisch wenn optional)"
|
||||
fi
|
||||
}
|
||||
|
||||
# ── Hauptdateien ──────────────────────────────────────────────────────────────
|
||||
install_file "app.py" "$INSTALL_DIR/app.py"
|
||||
ok "app.py installiert"
|
||||
|
||||
# ── Versionsdatei kopieren oder herunterladen ────────────────────────────────
|
||||
if [ -f "./version.txt" ]; then
|
||||
info "Lokale version.txt wird verwendet..."
|
||||
cp version.txt "$INSTALL_DIR/version.txt"
|
||||
else
|
||||
info "version.txt wird heruntergeladen..."
|
||||
curl -sSfL "$REPO_RAW/version.txt" -o "$INSTALL_DIR/version.txt" \
|
||||
|| fail "Download der version.txt fehlgeschlagen. Prüfe die Internet-Verbindung."
|
||||
fi
|
||||
install_file "version.txt" "$INSTALL_DIR/version.txt"
|
||||
ok "version.txt installiert"
|
||||
|
||||
# ── Logo kopieren oder herunterladen ─────────────────────────────────────────
|
||||
if [ -f "./PiCopy_Logo.png" ]; then
|
||||
info "Lokales Logo wird verwendet..."
|
||||
cp PiCopy_Logo.png "$INSTALL_DIR/PiCopy_Logo.png"
|
||||
else
|
||||
info "Logo wird heruntergeladen..."
|
||||
curl -sSfL "$REPO_RAW/PiCopy_Logo.png" -o "$INSTALL_DIR/PiCopy_Logo.png" \
|
||||
|| warn "Logo konnte nicht heruntergeladen werden (nicht kritisch)."
|
||||
fi
|
||||
install_file "PiCopy_Logo.png" "$INSTALL_DIR/PiCopy_Logo.png"
|
||||
ok "Logo installiert"
|
||||
|
||||
# ── picopy/ Paket ─────────────────────────────────────────────────────────────
|
||||
install_file "picopy/__init__.py" "$INSTALL_DIR/picopy/__init__.py"
|
||||
install_file "picopy/config.py" "$INSTALL_DIR/picopy/config.py"
|
||||
install_file "picopy/state.py" "$INSTALL_DIR/picopy/state.py"
|
||||
install_file "picopy/usb.py" "$INSTALL_DIR/picopy/usb.py"
|
||||
install_file "picopy/copy_engine.py" "$INSTALL_DIR/picopy/copy_engine.py"
|
||||
install_file "picopy/wifi.py" "$INSTALL_DIR/picopy/wifi.py"
|
||||
install_file "picopy/wireguard.py" "$INSTALL_DIR/picopy/wireguard.py"
|
||||
install_file "picopy/samba.py" "$INSTALL_DIR/picopy/samba.py"
|
||||
install_file "picopy/upload.py" "$INSTALL_DIR/picopy/upload.py"
|
||||
install_file "picopy/system.py" "$INSTALL_DIR/picopy/system.py"
|
||||
ok "picopy/-Paket installiert"
|
||||
|
||||
# ── routes/ Paket ─────────────────────────────────────────────────────────────
|
||||
install_file "routes/__init__.py" "$INSTALL_DIR/routes/__init__.py"
|
||||
install_file "routes/copy_routes.py" "$INSTALL_DIR/routes/copy_routes.py"
|
||||
install_file "routes/wifi_routes.py" "$INSTALL_DIR/routes/wifi_routes.py"
|
||||
install_file "routes/wireguard_routes.py" "$INSTALL_DIR/routes/wireguard_routes.py"
|
||||
install_file "routes/upload_routes.py" "$INSTALL_DIR/routes/upload_routes.py"
|
||||
install_file "routes/system_routes.py" "$INSTALL_DIR/routes/system_routes.py"
|
||||
install_file "routes/browse_routes.py" "$INSTALL_DIR/routes/browse_routes.py"
|
||||
ok "routes/-Paket installiert"
|
||||
|
||||
# ── templates/ ────────────────────────────────────────────────────────────────
|
||||
install_file "templates/index.html" "$INSTALL_DIR/templates/index.html"
|
||||
ok "Template installiert"
|
||||
|
||||
# ── Python-Umgebung ───────────────────────────────────────────────────────────
|
||||
info "Python venv wird erstellt..."
|
||||
python3 -m venv "$INSTALL_DIR/venv"
|
||||
|
||||
Reference in New Issue
Block a user