Skip to content
Snippets Groups Projects
Select Git revision
  • d471552351e37ef7dcf31537fe9d90655ef24e69
  • master default protected
  • 133-fail2ban-page
  • reorganisation
  • 16-maintenace-service
  • 11-fail2ban
  • 6-monit-update
  • 7-dolibarr-fail2ban
  • 6-surveillance-interne-des-serveur
  • test-glpi
  • 2-migrate-to-phpfpm
  • jessie
  • github
13 results

AptCacher.sh

Blame
  • AptCacher.sh 1.17 KiB
    #!/bin/bash
    
    echo "RUN $(basename "$0") ==="
    
    DIR=$(realpath $(dirname $0)/..)
    if [ ! -e $DIR/main.env ]
    then
        echo "Please copy in root of NoCloud Auto Installer main.env.sample to main.env and edit it"
        exit 1
    else
        echo "Environment file loaded"
    fi
    . $DIR/main.env
    
    apt-get update
    apt-get -y install apt-cacher-ng
    
    # Set port
    # Add PassThrough for HTTPS backends
    # Disable statistic page
    sed -i \
        -e 's/^# \(Port:3142\)/\1/' \
        -e 's/^# \(PassThroughPattern: \.\*\)/\1/' \
        -e 's/^\([^#]*ReportPage:.*$\)/#\1/' \
        /etc/apt-cacher-ng/acng.conf
    
    # Add mint backend
    if [ -z "`grep linuxmint /etc/apt-cacher-ng/acng.conf`" ]
    then
        cp $DIR/etc/apt-cacher-ng/backends_mint /etc/apt-cacher-ng/
        echo "Remap-linuxmint: file:backends_mint" >> \
            /etc/apt-cacher-ng/acng.conf
    fi
    
    # Start service
    systemctl start apt-cacher-ng.service
    systemctl enable apt-cacher-ng.service
    
    # Use proxy
    if [ -z "`grep Acquire::Http::Proxy /etc/apt/apt.conf.d/70debconf`" ]
    then
        echo 'Acquire::Http::Proxy "http://127.0.0.1:3142";' >> \
            /etc/apt/apt.conf.d/70debconf
    fi
    
    # Allow proxy on local network
    ufw allow from $(ip a | awk '/inet .* (eth|enp)/{print $2}') to any port 3142