Select Git revision
AptCacher.sh

Elian Loraux authored
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