UrNetwork-Stats-Dashboard-r.../install.sh

103 lines
2.8 KiB
Bash
Raw Permalink Normal View History

2025-11-21 22:39:41 +01:00
#!/bin/bash
# UrNetwork Stats Dashboard - Installation Script v2.1
# This script automates the installation process
set -e # Exit on error
echo "========================================="
echo "UrNetwork Stats Dashboard v2.1"
echo "Installation Script"
echo "========================================="
echo ""
# Check Python version
echo "[1/6] Checking Python version..."
if ! command -v python3 &> /dev/null; then
echo "❌ Python 3 is not installed!"
echo "Please install Python 3.8+ and try again."
exit 1
fi
PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
echo "✅ Python $PYTHON_VERSION found"
echo ""
# Check pip
echo "[2/6] Checking pip..."
if ! command -v pip3 &> /dev/null; then
echo "❌ pip3 is not installed!"
echo "Please install pip3 and try again."
exit 1
fi
echo "✅ pip3 found"
echo ""
# Install dependencies
echo "[3/6] Installing dependencies..."
echo "This may take a few minutes..."
pip3 install -r requirements.txt
echo "✅ Dependencies installed"
echo ""
# Create necessary directories
echo "[4/6] Creating directories..."
mkdir -p instance
echo "✅ Directories created"
echo ""
# Check if already installed
echo "[5/6] Checking existing installation..."
if [ -f ".env" ]; then
echo "⚠️ Found existing .env file"
read -p "Do you want to keep it? (y/n): " keep_env
if [ "$keep_env" != "y" ]; then
mv .env .env.backup
echo "✅ Backed up to .env.backup"
else
echo "✅ Keeping existing configuration"
fi
fi
if [ -f "instance/transfer_stats.db" ]; then
echo "⚠️ Found existing database"
read -p "Do you want to keep it? (y/n): " keep_db
if [ "$keep_db" != "y" ]; then
mv instance/transfer_stats.db instance/transfer_stats.db.backup
echo "✅ Backed up to transfer_stats.db.backup"
else
echo "✅ Keeping existing database"
fi
fi
echo ""
# Final instructions
echo "[6/6] Installation complete!"
echo ""
echo "========================================="
echo "🎉 Ready to start!"
echo "========================================="
echo ""
echo "To run the dashboard:"
echo " python3 main.py"
echo ""
echo "Then open your browser to:"
echo " http://localhost:90"
echo ""
echo "On first run, you will:"
echo " 1. Set your admin password"
echo " 2. Add your UrNetwork accounts"
echo ""
echo "For production deployment with Gunicorn:"
echo " gunicorn --bind 0.0.0.0:90 --workers 4 main:app"
echo ""
echo "For systemd service setup, see README.md"
echo ""
echo "📖 Documentation:"
echo " - README.md - Full documentation"
echo " - QUICKSTART.md - Quick start guide"
echo " - WEBHOOK_GUIDE.md - Webhook examples"
echo ""
echo "Need help? Check the docs or create an issue!"
echo "========================================="