Skip to content

Instantly share code, notes, and snippets.

@GeoffWilliams
Last active August 9, 2017 12:49
Show Gist options
  • Select an option

  • Save GeoffWilliams/8b3a1de8ba7971868c46 to your computer and use it in GitHub Desktop.

Select an option

Save GeoffWilliams/8b3a1de8ba7971868c46 to your computer and use it in GitHub Desktop.
debian/ubuntu magic proxy setting depending on assigned domain
#!/bin/bash
#
# /etc/network/if-up.d/apt-proxy
# set a proxy to use for apt depending what network we're on
APT_CONFIG="/etc/apt/apt.conf.d/10proxy"
HOME_NETWORK="lan.asio"
CACHE_SERVER="cache.${HOME_NETWORK}"
CACHE_PORT=3142
if [ "${DHCP4_DOMAIN_NAME}" == "${HOME_NETWORK}" ] ; then
ping -c 1 $CACHE_SERVER &> /dev/null
if [ $? = "0" ]; then
PROXY_LINE="Acquire::http::Proxy \"http://${CACHE_SERVER}:${CACHE_PORT}\";"
else
PROXY_LINE="# proxy not in use - On home network but ${CACHE_SERVER} is not pingable"
fi
else
PROXY_LINE='# proxy not in use - not on home network'
fi
echo $PROXY_LINE > $APT_CONFIG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment