Inital Commit

This commit is contained in:
2025-01-08 00:09:38 +01:00
commit 8725a44750
8 changed files with 872 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
#!/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"
CacheFedoraCache="http://$UseServer:80"
#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
FedoraCache='proxy = "'$CacheFedoraCache'"'
elif [ $UseCache = no ]; then
echo "Not using cache server"
AlpineRepo=$DefaultAlpineRepo
DebianCache='#CacheServer not set'
DebianCore=$DefaultDebianCore
FedoraCache='#CacheServer not set'
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\ {% if image.release != "edge" %}\n\ '$AlpineRepo'v{{ image.release }}/main\n\ '$AlpineRepo'v{{ image.release }}/community\n\ {% endif %}\n\ {% if image.release == "edge" %}\n\ '$AlpineRepo'edge/main\n\ '$AlpineRepo'edge/community\n\ \#'$AlpineRepo'edge/testing\n\ {% endif %}\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
#FedoraProxyCache
sed -i -e '/#ProxyCacheSetting/{n;d}' CT-Build/Fedora.yaml
sed -i -e "/#ProxyCacheSetting/a \ echo \'$FedoraCache\' >> /etc/dnf/dnf.conf" CT-Build/Fedora.yaml