102 lines
2.6 KiB
Bash
Executable file
102 lines
2.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Setup script for apt-cacher-ng to support Debian Forge development
|
|
# This script installs and configures apt-cacher-ng for local development
|
|
|
|
set -e
|
|
|
|
echo "Setting up apt-cacher-ng for Debian Forge development..."
|
|
|
|
# Check if running as root
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "This script must be run as root (use sudo)"
|
|
exit 1
|
|
fi
|
|
|
|
# Install apt-cacher-ng
|
|
echo "Installing apt-cacher-ng..."
|
|
if command -v dnf &> /dev/null; then
|
|
dnf install -y apt-cacher-ng
|
|
elif command -v apt &> /dev/null; then
|
|
apt update
|
|
apt install -y apt-cacher-ng
|
|
else
|
|
echo "No supported package manager found (dnf or apt)"
|
|
exit 1
|
|
fi
|
|
|
|
# Create configuration directory
|
|
mkdir -p /etc/apt-cacher-ng
|
|
|
|
# Configure apt-cacher-ng for Debian repositories
|
|
cat > /etc/apt-cacher-ng/acng.conf << 'EOF'
|
|
# apt-cacher-ng configuration for Debian Forge development
|
|
|
|
# Cache directory
|
|
CacheDir: /var/cache/apt-cacher-ng
|
|
|
|
# Log directory
|
|
LogDir: /var/log/apt-cacher-ng
|
|
|
|
# Port to listen on
|
|
Port: 3142
|
|
|
|
# Bind address (listen on all interfaces)
|
|
BindAddress: 192.168.1.101
|
|
|
|
# Verbose logging for development
|
|
VerboseLog: 1
|
|
|
|
# Allow access from localhost
|
|
AllowUser: *
|
|
|
|
# Cache Debian repositories
|
|
Backend: http://deb.debian.org/debian
|
|
Backend: http://deb.debian.org/debian-security
|
|
Backend: http://deb.debian.org/debian-backports
|
|
|
|
# Cache size limit (5GB)
|
|
MaxStandbyConcurrency: 10
|
|
MaxStandbyConcurrencyPerMirror: 2
|
|
MaxStandbyConcurrencyPerBackend: 2
|
|
|
|
# Keep packages for 30 days
|
|
ExTreshold: 30
|
|
EOF
|
|
|
|
# Start and enable apt-cacher-ng service
|
|
echo "Starting apt-cacher-ng service..."
|
|
systemctl daemon-reload
|
|
systemctl enable apt-cacher-ng
|
|
systemctl start apt-cacher-ng
|
|
|
|
# Check service status
|
|
if systemctl is-active --quiet apt-cacher-ng; then
|
|
echo "✅ apt-cacher-ng is running on http://192.168.1.101:3142"
|
|
echo "You can now use 'apt_proxy: \"http://192.168.1.101:3142\"' in your manifests"
|
|
else
|
|
echo "❌ Failed to start apt-cacher-ng service"
|
|
systemctl status apt-cacher-ng
|
|
exit 1
|
|
fi
|
|
|
|
# Test the proxy
|
|
echo "Testing apt-cacher-ng..."
|
|
if curl -s http://localhost:3142/acng-report.html > /dev/null; then
|
|
echo "✅ apt-cacher-ng is responding correctly"
|
|
else
|
|
echo "❌ apt-cacher-ng is not responding"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "apt-cacher-ng setup complete!"
|
|
echo ""
|
|
echo "Usage in your manifests:"
|
|
echo " \"apt_proxy\": \"http://192.168.1.101:3142\""
|
|
echo ""
|
|
echo "To view cache statistics: http://localhost:3142/acng-report.html"
|
|
echo "To view cache contents: http://localhost:3142/deb.debian.org/debian/"
|
|
echo ""
|
|
echo "To stop the service: sudo systemctl stop apt-cacher-ng"
|
|
echo "To start the service: sudo systemctl start apt-cacher-ng"
|