kaz-vagrant/files/customVM.sh.dist

43 lines
1.2 KiB
Plaintext
Raw Normal View History

2023-03-02 10:49:20 +01:00
#!/bin/bash
2023-03-02 16:48:10 +01:00
PROXY="192.168.0.121:3128"
REGISTRY="192.168.0.121:5000"
2023-03-02 10:49:20 +01:00
2023-03-02 16:48:10 +01:00
# Pour le proxy http/https (https sans cache) avec iptables
cat >> /etc/rc.local <<EOF
#!/bin/sh
PROXY=${PROXY}
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 3142 -j DNAT --to \${PROXY}
iptables -t nat -A OUTPUT -p tcp -m tcp --dport 3142 -j DNAT --to \${PROXY}
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
EOF
chmod +x /etc/rc.local
echo "net.ipv4.conf.eth0.route_localnet=1" >> /etc/sysctl.conf
sysctl -p
# fin proxy
2023-03-02 10:49:20 +01:00
2023-03-02 16:48:10 +01:00
# Pour le cache docker
cat >> /etc/rc.local <<EOF
REGISTRY=${REGISTRY}
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 5000 -j DNAT --to \${REGISTRY}
EOF
# fin cache docker
bash /etc/rc.local
2023-03-02 10:49:20 +01:00
# Un peu de customisation
DEBIAN_FRONTEND=noninteractive apt-get install -y vim rsync
rsync -a /vagrant/files/.emacs* /root/
2023-03-02 16:48:10 +01:00
###
# Une autre façon de router vers un autre proxy http/https upstream, si on veut que la VM fasse le cache
###
# Pour le proxy http/https (https sans cache) avec squid config
#echo "cache_peer $(cut -d':' -f1 <<< $PROXY) parent $(cut -d':' -f2 <<< $PROXY) 0 no-query default
#acl all src 0.0.0.0/0.0.0.0
#http_access allow all
#never_direct allow all" >> /etc/squid/squid.conf
#service squid restart