Inital Commit

This commit is contained in:
2021-09-14 18:03:20 +02:00
commit e32bd0cac6
15 changed files with 1789 additions and 0 deletions

39
Scripts/FirstSetup.sh Normal file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
#Vars
#Goto ProjectRoot
cd "$( cd "$( dirname "$0" )" &> /dev/null && pwd )/.."
echo "The script will now install required dependencies"
read -r -s -p $'Press enter to continue, or ctrl+c to quit'
#Install software dependencies
apt install ca-certificates golang git make debootstrap curl gcc libc-dev nano gnupg2 rsync xz-utils --no-install-recommends -y
#Get Source for DistroBuilder
git clone https://github.com/lxc/distrobuilder distrobuilderSRC
cd distrobuilderSRC
#Run Build for Build
gofmt -s -w .
go build -o ../ -v ./...
#Cleanup
cd ../
rm -rf distrobuilderSRC
#Disable use of cache Server
bash Scripts/UpdateIMGBuildFile-CacheAndRepo.sh -d
#Allow XZ to use all cores
export XZ_DEFAULTS="-T 0"
#Function for building LXC images
BuildImage () {
local Distro=$1
local Variant=$2
./distrobuilder build-lxc CT-Build/$Distro.yaml -o image.variant=$Variant
rm -f meta.tar.xz
mv ./rootfs.tar.xz "$Distro-$Variant".tar.xz
}
#Build Jenkins Image
BuildImage Debian jenkins
#Build JenkinsNode (imgbuilder) Image
BuildImage Debian imgbuilder

View File

@@ -0,0 +1,64 @@
#!/bin/bash
#Allow for external definiton of status of cache
StatusFlag=$1
#UserSettings
ThisScriptConfigured=no
UseCache=no
#Cache enable (using apt-cacher-NG)
CacheAlpineRepo="http://192.168.2.83/alpine/"
CacheDebianCache="http://192.168.2.83:80"
CacheDebianCore="http://192.168.2.83/deb.debian.org/debian"
#Cache enable (using Official MirrorServers)
DefaultAlpineRepo="http://dl-4.alpinelinux.org/alpine/"
DefaultDebianCore="http://deb.debian.org/debian"
###Do not Edit underneath###
#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"
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 )/.."
#AlpineBaseRepo
sed -i -e '/#InitDownloadREPO/{n;d}' CT-Build/Alpine.yaml
sed -i -e '/#InitDownloadREPO/a \ url: '$AlpineRepo'' 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/latest-stable/main'\n\ '$AlpineRepo'latest-stable/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