#! /bin/sh

kwartzHere=1

ping -c 1 172.16.0.254 > /dev/null 2>&1 || kwartzHere=0

if [ $kwartzHere = 0 ]; then
    # c'est un environnement autre, il n'y a pas de Kwartz
    rm -f /etc/profile.d/kwartz-proxy.sh
    rm -f /etc/apt/apt.conf.d/99kwartz-proxy
    sed -i '/http_proxy = 175.16.0.254:3128/ d' /etc/wgetrc
else
    echo "export http_proxy=http://192.168.0.1:3128" > /etc/profile.d/kwartz-proxy.sh
    echo 'Acquire::http::Proxy "http://172.16.0.254:3128";' > /etc/apt/apt.conf.d/99kwartz-proxy
    sed -i '$ a http_proxy = 172.16.0.254:3128' /etc/wgetrc
fi
