Files
Claude Code 6d74d874b6 ZMB Webui: Complete Project – Rebrand & Initial Clean Commit
ARCHITECTURE
============
Backend: FastAPI + uvicorn (port 8000)
  - JWT authentication with PAM system users
  - ZFS CLI wrapper with caching (30-60s TTL)
  - WebSocket pool status broadcaster (30s interval)
  - Services: auth, zfs_runner, file_manager, shares, identities, system_info
  - Routers: pools, datasets, snapshots, shares, identities, navigator, system

Frontend: Next.js 15 + TypeScript (static export)
  - Incremental Static Regeneration (ISR) for weak hardware
  - Type-safe API client (lib/api.ts)
  - Dark mode + custom Tailwind theme
  - Pages: Dashboard, Login, Snapshots, Datasets, Shares, etc.

DEPLOYMENT
==========
Test Target: 192.168.1.179:8090 (Debian LXC)
Production: 10.66.120.3:9090 (Raspberry Pi 4GB ARM64)
Updater: Automated Gitea-based deployment (update-test.sh, update-pi.sh)

FEATURES COMPLETED
==================
Phase 3a: Dashboard Quick Stats (System, CPU, Memory, Storage)
  - Real-time stats with color-coded progress bars
  - Responsive grid layout (mobile: 1, tablet: 2, desktop: 4 columns)
  - ISR-optimized for fast loads on weak hardware

REBRANDING
==========
Renamed throughout:
  - Project: 'ZFS Manager' → 'ZMB Webui'
  - Services: 'zfs-manager' → 'zmb-webui'
  - Systemd units: zfs-manager-backend → zmb-webui-backend
  - Configuration files and documentation

Co-Authored-By: Patrick <patrick@perlbach24.de>
2026-04-22 00:43:05 +02:00

129 lines
3.6 KiB
Bash
Executable File

#!/bin/bash
# Installation script for ZMB Webui Backend on Raspberry Pi
# Run as root: sudo bash install.sh
set -e
echo "=== ZMB Webui Backend Installation ==="
echo ""
# Check if running as root
if [[ $EUID -ne 0 ]]; then
echo "ERROR: This script must be run as root (use: sudo bash install.sh)"
exit 1
fi
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Configuration
INSTALL_PATH="/opt/zmb-webui"
VENV_PATH="${INSTALL_PATH}/venv"
SYSTEMD_USER="root"
echo -e "${YELLOW}Step 1: Checking prerequisites & architecture${NC}"
# Detect architecture
ARCH=$(uname -m)
echo " - Architecture: $ARCH"
case $ARCH in
aarch64) ARCH_NAME="ARM64 (Raspberry Pi)" ;;
x86_64) ARCH_NAME="AMD64 (64-bit)" ;;
i686) ARCH_NAME="x86 (32-bit)" ;;
*) ARCH_NAME="$ARCH (unknown)" ;;
esac
echo "$ARCH_NAME"
# Detect OS
if [ -f /etc/os-release ]; then
. /etc/os-release
OS_NAME="${NAME:-Unknown}"
echo " - OS: $OS_NAME"
else
echo -e "${YELLOW}WARNING: Could not detect OS${NC}"
fi
echo " - Python 3.11+"
python3 --version || { echo -e "${RED}ERROR: Python 3.11+ required${NC}"; exit 1; }
echo " - ZFS tools"
which zpool > /dev/null || { echo -e "${RED}ERROR: zpool not found${NC}"; exit 1; }
which zfs > /dev/null || { echo -e "${RED}ERROR: zfs not found${NC}"; exit 1; }
echo " - pip"
python3 -m pip --version > /dev/null || { echo -e "${RED}ERROR: pip not found${NC}"; exit 1; }
echo -e "${GREEN}✓ Prerequisites OK${NC}"
echo ""
echo -e "${YELLOW}Step 2: Creating installation directory${NC}"
mkdir -p "${INSTALL_PATH}"
cp -r . "${INSTALL_PATH}/backend"
echo -e "${GREEN}✓ Backend copied to ${INSTALL_PATH}/backend${NC}"
echo ""
echo -e "${YELLOW}Step 3: Creating Python virtual environment${NC}"
python3 -m venv "${VENV_PATH}"
source "${VENV_PATH}/bin/activate"
echo -e "${GREEN}✓ Virtual environment created${NC}"
echo ""
echo -e "${YELLOW}Step 4: Installing dependencies${NC}"
pip install --upgrade pip setuptools wheel > /dev/null
pip install -r "${INSTALL_PATH}/backend/requirements.txt"
echo -e "${GREEN}✓ Dependencies installed${NC}"
echo ""
echo -e "${YELLOW}Step 5: Setting up default admin user${NC}"
cd "${INSTALL_PATH}/backend"
python3 << EOF
import sys
sys.path.insert(0, '.')
from services.auth import auth_service
# Check if admin exists
if 'admin' not in auth_service.users:
print("Creating default admin user...")
auth_service.add_user('admin', 'admin123')
print("✓ Admin user created (username: admin, password: admin123)")
print("⚠️ CHANGE PASSWORD IMMEDIATELY!")
else:
print("✓ Admin user already exists")
EOF
echo ""
echo -e "${YELLOW}Step 6: Installing systemd service${NC}"
cp deploy/zmb-webui-backend.service /etc/systemd/system/
systemctl daemon-reload
echo -e "${GREEN}✓ Systemd service installed${NC}"
echo ""
echo -e "${YELLOW}Step 7: Setting permissions${NC}"
chown -R root:root "${INSTALL_PATH}"
chmod 750 "${INSTALL_PATH}/backend"
chmod 640 "${INSTALL_PATH}/backend/config/users.json"
echo -e "${GREEN}✓ Permissions set${NC}"
echo ""
echo -e "${GREEN}=== Installation Complete ===${NC}"
echo ""
echo "Next steps:"
echo " 1. Review and update admin password:"
echo " systemctl start zmb-webui-backend"
echo " curl http://localhost:8000/health"
echo ""
echo " 2. Enable service to start on boot:"
echo " systemctl enable zmb-webui-backend"
echo ""
echo " 3. Check logs:"
echo " journalctl -u zmb-webui-backend -f"
echo ""
echo " 4. Test API:"
echo " curl -X POST http://localhost:8000/api/auth/login \\"
echo " -H 'Content-Type: application/json' \\"
echo " -d '{\"username\":\"admin\",\"password\":\"admin123\"}'"
echo ""