#!/bin/bash #Allow for external definiton of status of cache StatusFlag=$1 ProxyFlag=$2 #UserSettings ThisScriptConfigured=no UseCache=no #Cache server if flag not set enable (using apt-cacher-NG) ConfigProxyServer="192.168.200.11" #Cache enable (using Official MirrorServers) DefaultAlpineRepo="https://dl-4.alpinelinux.org/alpine/" DefaultDebianCore="http://deb.debian.org/debian" ###Do not Edit underneath### if [ -n "$ProxyFlag" ]; then UseServer="$ProxyFlag" else UseServer="$ConfigProxyServer" fi CacheAlpineRepo="http://$UseServer/alpine/" CacheDebianCache="http://$UseServer:80" CacheDebianCore="http://$UseServer/deb.debian.org/debian" #Check if using StatusFlag if not chek if scipt is configured if [ -n "$StatusFlag" ]; then if [ $StatusFlag = "-e" ]; then UseCache=yes elif [ $StatusFlag = "-d" ]; then UseCache=no fi elif [ $ThisScriptConfigured = no ]; then echo "Script is not configured" exit fi #Check if using Cache if [ $UseCache = yes ]; then echo "Using cache server $UseServer" AlpineRepo=$CacheAlpineRepo DebianCache='Acquire::http::Proxy "'$CacheDebianCache'";' DebianCore=$CacheDebianCore elif [ $UseCache = no ]; then echo "Not using cache server" AlpineRepo=$DefaultAlpineRepo DebianCache='#CacheServer not set' DebianCore=$DefaultDebianCore fi #Goto ProjectRoot cd "$( cd "$( dirname "$0" )" &> /dev/null && pwd )/.." #AlpineCoreRepo ## Disabled using the proxy server and will now always use $DefaultAlpineRepo instead of $AlpineRepo. ## This is due to a change in the downloading of the minirootfs for alpine in Distrobuilder [since 22-08-2022] (Note: Distrobuilder will store the image in the tmp folder) sed -i -e '/#InitDownloadREPO/{n;d}' CT-Build/Alpine.yaml sed -i -e '/#InitDownloadREPO/a \ url: '$DefaultAlpineRepo'' CT-Build/Alpine.yaml #AlpineRepo sed -i -n '/#StartREPOS/{:a;N;/#EndREPOS/!ba;N;s/.*\n/#HereREPO\n/};p' CT-Build/Alpine.yaml sed -i -e 's#\#HereREPO#\ \#StartREPOS\n\ '$AlpineRepo'v{{ image.release }}/main\n\ '$AlpineRepo'v{{ image.release }}/community\n\ \#EndREPOS#g' CT-Build/Alpine.yaml #DebianBaseRepo sed -i -e '/#InitDownloadREPO/{n;d}' CT-Build/Debian.yaml sed -i -e '/#InitDownloadREPO/a \ url: '$DebianCore'' CT-Build/Debian.yaml #DebianProxyCache sed -i -e '/#ProxyCacheSetting/{n;d}' CT-Build/Debian.yaml sed -i -e "/#ProxyCacheSetting/a \ echo \'$DebianCache\' > /etc/apt/apt.conf.d/01prox" CT-Build/Debian.yaml