瀏覽代碼

migrate to apt mirror 2

Denys Bashkatov 3 周之前
父節點
當前提交
b2dd04daa8

+ 6 - 2
Dockerfile

@@ -1,9 +1,10 @@
 # Multi-stage build for apt-mirror with nginx
-FROM ubuntu:24.04 as base
+FROM ubuntu:24.04 AS base
 
 # Install system dependencies
 RUN apt-get update && apt-get install -y \
-    apt-mirror \
+    python3 \
+    python3-pip \
     nginx \
     openssl \
     curl \
@@ -14,6 +15,9 @@ RUN apt-get update && apt-get install -y \
     net-tools \
     && rm -rf /var/lib/apt/lists/*
 
+# Install apt-mirror from PyPI (using --break-system-packages for Ubuntu 24.04)
+RUN pip3 install --break-system-packages apt-mirror
+
 # Create necessary directories
 RUN mkdir -p /var/spool/apt-mirror \
     && mkdir -p /var/www/mirror.intra \

+ 5 - 4
README.md

@@ -4,7 +4,7 @@ A comprehensive APT mirror solution with a modern web interface, built with Dock
 
 ## 🚀 Features
 
-- **APT Mirror**: Local Ubuntu package repository with automatic synchronization
+- **APT Mirror**: Local Ubuntu package repository with automatic synchronization using apt-mirror2 (Python/asyncio version) from PyPI
 - **Web Interface**: web UI for all services
 - **Multi-Host Setup**: Three distinct web services:
   - `mirror.intra` - DEB packages repository
@@ -28,8 +28,9 @@ A comprehensive APT mirror solution with a modern web interface, built with Dock
 │                    UI APT Mirror Container                  │
 ├─────────────────────────────────────────────────────────────┤
 │  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐        │
-│  │   nginx     │  │ apt-mirror  │  │ health-check│        │
+│  │   nginx     │  │ apt-mirror2 │  │ health-check│        │
 │  │   (web)     │  │   (sync)    │  │  (monitor)  │        │
+│  │             │  │  (Python)   │  │             │        │
 │  └─────────────┘  └─────────────┘  └─────────────┘        │
 ├─────────────────────────────────────────────────────────────┤
 │  mirror.intra  │  admin.mirror.intra  │  files.mirror.intra │
@@ -109,7 +110,7 @@ The following directories are automatically created and mounted:
 
 ### APT Mirror Configuration
 
-The apt-mirror configuration is automatically generated and includes:
+The apt-mirror2 configuration is automatically generated and includes:
 - Ubuntu 24.04 (Noble Numbat) repositories
 - Debian 12 (Bookworm) repositories
 - Main, restricted, universe, and multiverse components
@@ -282,6 +283,6 @@ This project is licensed under the MIT License - see the LICENSE file for detail
 
 ## 🙏 Acknowledgments
 
-- [apt-mirror](https://github.com/apt-mirror/apt-mirror) - The APT mirroring tool
+- [apt-mirror2](https://gitlab.com/apt-mirror2/apt-mirror2) - The Python/asyncio APT mirroring tool from PyPI
 - [nginx](https://nginx.org/) - Web server
 - [Docker](https://docker.com/) - Containerization platform

+ 4 - 4
admin/app/routes/documentation/documentation.tsx

@@ -37,7 +37,7 @@ export default function Documentation() {
 {`data/
 ├── conf/
 │   ├── apt-mirror/
-│   │   └── mirror.list          # apt-mirror configuration
+│   │   └── mirror.list          # apt-mirror2 configuration
 │   └── nginx/
 │       ├── .htpasswd            # Admin authentication file
 │       └── sites-available/     # Nginx site configurations
@@ -45,14 +45,14 @@ export default function Documentation() {
 │           ├── admin.mirror.intra.conf
 │           └── files.mirror.intra.conf
 ├── data/
-│   ├── apt-mirror/              # apt-mirror working directory
+│   ├── apt-mirror/              # apt-mirror2 working directory
 │   │   ├── mirror/              # Downloaded package mirrors
 │   │   ├── skel/                # Skeleton files
 │   │   └── var/                 # Variable data
 │   └── files/                   # Custom file repository
 └── logs/
-    ├── apt-mirror/              # apt-mirror logs
-    │   └── apt-mirror.log       # Main apt-mirror log file
+    ├── apt-mirror/              # apt-mirror2 logs
+    │   └── apt-mirror.log       # Main apt-mirror2 log file
     └── nginx/                   # Nginx access and error logs`}
           </pre>
         </div>

+ 2 - 2
admin/app/routes/file-manager/file-manager.tsx

@@ -36,10 +36,10 @@ export function shouldRevalidate({
   return defaultShouldRevalidate;
 }
 
-export function meta() {
+export function meta({}: any) {
   return [
     { title: "File Manager" },
-    { name: "description", content: "File Manager for apt-mirror" },
+    { name: "description", content: "File Manager for apt-mirror2" },
   ];
 }
 

+ 5 - 5
entrypoint.sh

@@ -77,14 +77,14 @@ fi
 
 echo "✅ nginx started successfully (PID: $NGINX_PID)"
 
-# Start apt-mirror sync in background if configuration exists
+# Start apt-mirror2 sync in background if configuration exists
 if [ -f /etc/apt/mirror.list ]; then
-    echo "🔄 Starting apt-mirror sync..."
+    echo "🔄 Starting apt-mirror2 sync..."
     /usr/local/bin/mirror-sync.sh &
     MIRROR_PID=$!
-    echo "✅ apt-mirror sync started (PID: $MIRROR_PID)"
+    echo "✅ apt-mirror2 sync started (PID: $MIRROR_PID)"
 else
-    echo "⚠️  No apt-mirror configuration found. Skipping sync."
+    echo "⚠️  No apt-mirror2 configuration found. Skipping sync."
 fi
 
 # Start health check service
@@ -96,7 +96,7 @@ echo "🎉 All services started successfully!"
 echo "📊 Services running:"
 echo "   - nginx (PID: $NGINX_PID)"
 if [ -n "$MIRROR_PID" ]; then
-    echo "   - apt-mirror sync (PID: $MIRROR_PID)"
+    echo "   - apt-mirror2 sync (PID: $MIRROR_PID)"
 fi
 echo "   - health check (PID: $HEALTH_PID)"
 

+ 3 - 3
scripts/health-check.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 
-# Health check script for apt-mirror container
-# This script monitors the health of nginx and apt-mirror services
+# Health check script for apt-mirror2 container
+# This script monitors the health of nginx and apt-mirror2 services
 
 HEALTH_LOG="/var/log/health-check.log"
 NGINX_PID_FILE="/var/run/nginx.pid"
@@ -36,7 +36,7 @@ check_nginx() {
     fi
 }
 
-# Function to check apt-mirror status
+# Function to check apt-mirror2 status
 check_mirror() {
     if [ -f "$MIRROR_LOCK_FILE" ]; then
         local pid=$(cat "$MIRROR_LOCK_FILE")

+ 4 - 4
scripts/mirror-sync.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 
-# apt-mirror sync script
-# This script handles the synchronization of apt repositories
+# apt-mirror2 sync script
+# This script handles the synchronization of apt repositories using the Python version (apt-mirror2)
 
 MIRROR_CONFIG="/etc/apt/mirror.list"
 MIRROR_LOG="/var/log/apt-mirror/apt-mirror.log"
@@ -42,7 +42,7 @@ remove_lock() {
 
 # Function to perform sync
 do_sync() {
-    log "Starting apt-mirror sync..."
+    log "Starting apt-mirror2 sync..."
     
     if [ ! -f "$MIRROR_CONFIG" ]; then
         log "ERROR: Mirror configuration not found at $MIRROR_CONFIG"
@@ -52,7 +52,7 @@ do_sync() {
     # Create lock file
     create_lock
     
-    # Run apt-mirror
+    # Run apt-mirror2 using Python version
     if apt-mirror "$MIRROR_CONFIG" 2>&1 | tee -a "$MIRROR_LOG"; then
         log "Sync completed successfully"
         

+ 4 - 4
setup.sh

@@ -206,14 +206,14 @@ create_data_dirs() {
     print_success "Data directories created."
 }
 
-# Function to generate apt-mirror configuration
+# Function to generate apt-mirror2 configuration
 generate_mirror_config() {
     local domain=$1
     
-    print_status "Generating apt-mirror configuration..."
+    print_status "Generating apt-mirror2 configuration..."
     
     cat > data/conf/apt-mirror/mirror.list << EOF
-# apt-mirror configuration for $domain
+# apt-mirror2 configuration for $domain
 # Generated on $(date)
 
 # Set base_path to the directory where you want to store the mirror
@@ -264,7 +264,7 @@ clean http://deb.debian.org/debian
 clean http://security.debian.org/debian-security
 EOF
     
-    print_success "apt-mirror configuration generated."
+    print_success "apt-mirror2 configuration generated."
 }
 
 # Function to show status