28 lines
1011 B
Bash
28 lines
1011 B
Bash
#!/bin/bash
|
|
|
|
if [ -d "/var/cache/apt-cacher-ng" ]; then
|
|
chown apt-cacher-ng:apt-cacher-ng apt-cacher-ng
|
|
fi
|
|
|
|
apt install -y rinetd apt-cacher-ng
|
|
|
|
cat > /etc/apt-cacher-ng/backend_archlx << "EOF"
|
|
#### HTTPS not supported ####
|
|
|
|
http://archlinux.puzzle.ch/
|
|
EOF
|
|
systemctl restart apt-cacher-ng
|
|
|
|
sed -i '/^# bindadress.*/a 0.0.0.0 8080 127.0.0.1 3142' /etc/rinetd.conf
|
|
sed -i '/^# bindadress.*/a 0.0.0.0 80 127.0.0.1 3142' /etc/rinetd.conf
|
|
systemctl restart rinetd
|
|
|
|
echo "Acquire::http { Proxy \"http://127.0.0.1\"; };" > /etc/apt/apt.conf.d/02proxy
|
|
|
|
if [ -f "/etc/iptables/rules.v4" ]; then
|
|
sed -i '/^-A INPUT -i lo -j ACCEPT.*/a -A INPUT -p tcp -m tcp --dport 8080 -m state --state NEW -j ACCEPT' /etc/iptables/rules.v4
|
|
sed -i '/^-A INPUT -i lo -j ACCEPT.*/a -A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT' /etc/iptables/rules.v4
|
|
sed -i '/^-A INPUT -i lo -j ACCEPT.*/a # apt-cacher-ng' /etc/iptables/rules.v4
|
|
iptables-restore /etc/iptables/rules.v4
|
|
fi
|