From f9b16207d82c76536ba440df2fea926031dd8607 Mon Sep 17 00:00:00 2001 From: Francois Lesueur Date: Wed, 1 Mar 2023 14:55:48 +0100 Subject: [PATCH] =?UTF-8?q?passage=20=C3=A0=20squid,=20de=20la=20VM=20aux?= =?UTF-8?q?=20dockers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/snster-kaz/kaz/prod/provision.sh | 23 ++++++++++++++++++++++- files/vm-provision.sh | 12 +++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/files/snster-kaz/kaz/prod/provision.sh b/files/snster-kaz/kaz/prod/provision.sh index d1dd130..182fb9c 100644 --- a/files/snster-kaz/kaz/prod/provision.sh +++ b/files/snster-kaz/kaz/prod/provision.sh @@ -18,7 +18,7 @@ DEBIAN_FRONTEND=noninteractive apt-get autoremove -y # KAZ specific things #installation de docker, docker-compose et on y fourre le user debian dans le groupe idoine -DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-compose docker-clean git apg curl sudo unzip rsync btrfs-progs ldap-utils # fuse-overlayfs +DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-compose docker-clean git apg curl sudo unzip rsync btrfs-progs ldap-utils # fuse-overlayfs usermod -G docker debian # activation dans alias dans /root/.bashrc sed -i \ @@ -80,6 +80,27 @@ fi echo -e '#!/bin/sh\n/kaz/bin/container.sh start' >> /etc/rc.local chmod +x /etc/rc.local +# On sauve le proxy APT +proxy=$(/sbin/ip route | awk '/default/ { print $3 }' | head -1) +sed -i -e "s/^proxy.*$/proxy=$proxy/" /usr/local/sbin/detect_proxy.sh +#echo "export http_proxy=\"http://$proxy:3142\"" > /etc/profile.d/proxy.sh +#echo "export https_proxy=\"http://$proxy:3142\"" >> /etc/profile.d/proxy.sh +mkdir /root/.docker +echo "{ + \"proxies\": + { + \"default\": + { + \"httpProxy\": \"http://$proxy:3142\", + \"httpsProxy\": \"http://$proxy:3142\", + \"noProxy\": \"*.sns,127.0.0.0/8\" + } + } +}" > /root/.docker/config.json +echo "http_proxy=\"http://$proxy:3142\" +https_proxy=\"http://$proxy:3142\" +" >> /etc/default/docker + # clear apt cache DEBIAN_FRONTEND=noninteractive apt-get autoremove -y DEBIAN_FRONTEND=noninteractive apt-get clean diff --git a/files/vm-provision.sh b/files/vm-provision.sh index 6e27df5..183fff6 100755 --- a/files/vm-provision.sh +++ b/files/vm-provision.sh @@ -25,10 +25,16 @@ export DebugLog="${VAGRANT_SRC_DIR}/log/log-vagrant-$(date +%y-%m-%d-%T)-" apt-get --allow-releaseinfo-change update # Cache APT - DEBIAN_FRONTEND=noninteractive apt-get install -y apt-cacher # apt-cacher-ng does not work well on bullseye - echo "allowed_hosts = *" >> /etc/apt-cacher/apt-cacher.conf - service apt-cacher restart + #DEBIAN_FRONTEND=noninteractive apt-get install -y apt-cacher # apt-cacher-ng does not work well on bullseye + #echo "allowed_hosts = *" >> /etc/apt-cacher/apt-cacher.conf + #service apt-cacher restart + DEBIAN_FRONTEND=noninteractive apt-get install -y squid + sed -i -e "s/#http_access allow localnet/http_access allow localnet/" /etc/squid/squid.conf + echo "cache_dir aufs /var/spool/squid 5000 14 256 +http_port 3142" >> /etc/squid/squid.conf + service squid restart echo "Acquire::http::Proxy \"http://127.0.0.1:3142\";" > /etc/apt/apt.conf.d/01proxy; # utilisation de apt-cacher-ng + # Ajouter http://www.squid-cache.org/Doc/config/cache_peer/ à squid pour un proxy upstream # MAJ et Install DEBIAN_FRONTEND=noninteractive apt-get -y upgrade