#!/bin/bash
HTMLDIR="/var/www/voidbuilds.xyz/public"
FILENAME="status.html"
ISODIR="download"
echo "refreshing repo cache"
xbps-install -S
mvImages(){
PKGLISTDIR="package_lists"
if [ ! -f sha256sums.txt ];then
echo "checksum file not found, aborting!"
exit 1
fi
if [ -d "${HTMLDIR}" ];then
rm ${HTMLDIR}/${ISODIR}/*.iso
rm ${HTMLDIR}/${ISODIR}/*.txt
rm ${HTMLDIR}/${ISODIR}/*.sig
mv sha256sums.txt build
mv sha256sums.txt.sig build
mv build/* ${HTMLDIR}/${ISODIR}
else
echo "${HTMLDIR}/${ISODIR} does not exist"
fi
if [ ! -d "${PKGLISTDIR}" ];then
mkdir "${PKGLISTDIR}"
fi
rm ${PKGLISTDIR}/*
cp base-x64.packages ${PKGLISTDIR}/base-x64.packages.txt
cp cinnamon-x64.packages ${PKGLISTDIR}/cinnamon-x64.packages.txt
cp e17-x64.packages ${PKGLISTDIR}/e17-x64.packages.txt
cp mate-x64.packages ${PKGLISTDIR}/mate-x64.packages.txt
cp lxde-x64.packages ${PKGLISTDIR}/lxde-x64.packages.txt
cp lxqt-x64.packages ${PKGLISTDIR}/lxqt-x64.packages.txt
cp i3-x64.packages ${PKGLISTDIR}/i3-x64.packages.txt
#cp kde-x64.packages ${PKGLISTDIR}/kde-x64.packages.txt
#cp gnome-x64.packages ${PKGLISTDIR}/gnome-x64.packages.txt
cp xfce-x64.packages ${PKGLISTDIR}/xfce-x64.packages.txt
cp -r ${PKGLISTDIR} ${HTMLDIR}
return
}
runBuilds(){
TOTAL="8"
ERR_FILE="error-status.txt"
if [ -f "${ERR_FILE}" ];then
echo "removing error file"
rm ${ERR_FILE}
fi
if [ ! -z "$(ls -A build)" ];then
rm build/*
fi
echo "0/${TOTAL} completed at $(date +%T)" >> ${HTMLDIR}/${FILENAME}
echo "Building Image: Base" >> ${HTMLDIR}/${FILENAME}
echo "Building: Base Image..."
sleep 1
./base-x64.sh
if [ $(cat ${ERR_FILE}) = "ERR=1" ];then
echo "Build failed for image: 'base', trying again at 00:00 MST" >> ${HTMLDIR}/${FILENAME}
rm ${ERR_FILE}
${0} -bl
else
echo "1/${TOTAL} completed at $(date +%T)" >> ${HTMLDIR}/${FILENAME}
fi
echo "Building Image: Cinnamon" >> ${HTMLDIR}/${FILENAME}
echo " Building: Cinnamon Image..."
sleep 1
./cinnamon-x64.sh
if [ $(cat ${ERR_FILE}) = "ERR=1" ];then
echo "Build failed for image: 'Cinnamon', trying again at 00:00 MST" >> ${HTMLDIR}/${FILENAME}
rm ${ERR_FILE}
${0} -bl
else
echo "2/${TOTAL} completed at $(date +%T)" >> ${HTMLDIR}/${FILENAME}
fi
#echo "Building Image: GNOME" >> ${HTMLDIR}/${FILENAME}
#echo " Building: Gnome Image..."
#sleep 1
#./gnome-x64.sh
echo "Building Image: i3" >> ${HTMLDIR}/${FILENAME}
echo "Building: i3 image..."
sleep 1
./i3-x64.sh
if [ $(cat ${ERR_FILE}) = "ERR=1" ];then
echo "Build failed for image: 'i3', trying again at 00:00 MST" >> ${HTMLDIR}/${FILENAME}
rm ${ERR_FILE}
${0} -bl
else
echo "3/${TOTAL} completed at $(date +%T)" >> ${HTMLDIR}/${FILENAME}
fi
echo "Building Image: Enlightenment" >> ${HTMLDIR}/${FILENAME}
echo "Building: enlightenment image..."
sleep 1
./e17-x64.sh
if [ $(cat ${ERR_FILE}) = "ERR=1" ];then
echo "Build failed for image: 'i3', trying again at 00:00 MST" >> ${HTMLDIR}/${FILENAME}
rm ${ERR_FILE}
${0} -bl
else
echo "4/${TOTAL} completed at $(date +%T)" >> ${HTMLDIR}/${FILENAME}
fi
#echo "Building Image: KDE" >> ${HTMLDIR}/${FILENAME}
#echo "Building: Kde image..."
#sleep 1
#./kde-x64.sh
echo "Building Image: LXDE" >> ${HTMLDIR}/${FILENAME}
echo "Building: Lxde Image..."
sleep 1
./lxde-x64.sh
if [ $(cat ${ERR_FILE}) = "ERR=1" ];then
echo "Build failed for image: 'LXDE', trying again at 00:00 MST" >> ${HTMLDIR}/${FILENAME}
rm ${ERR_FILE}
${0} -bl
else
echo "5/${TOTAL} completed at $(date +%T)" >> ${HTMLDIR}/${FILENAME}
fi
echo "Building Image: LXQT" >> ${HTMLDIR}/${FILENAME}
echo "Building: Lxqt Image..."
sleep 1
./lxqt-x64.sh
if [ $(cat ${ERR_FILE}) = "ERR=1" ];then
echo "Build failed for image: 'LXQT', trying again at 00:00 MST" >> ${HTMLDIR}/${FILENAME}
rm ${ERR_FILE}
${0} -bl
else
echo "6/${TOTAL} completed at $(date +%T)" >> ${HTMLDIR}/${FILENAME}
fi
echo "Building Image: MATE" >> ${HTMLDIR}/${FILENAME}
echo "Building: Mate Image..."
sleep 1
./mate-x64.sh
if [ "$(cat ${ERR_FILE})" = "ERR=1" ];then
echo "Build failed for image: 'MATE', trying again at 00:00 MST" >> ${HTMLDIR}/${FILENAME}
rm ${ERR_FILE}
${0} -bl
else
echo "7/${TOTAL} completed at $(date +%T)" >> ${HTMLDIR}/${FILENAME}
fi
echo "Building Image: XFCE" >> ${HTMLDIR}/${FILENAME}
echo "Building: Xfce Image..."
sleep 1
./xfce-x64.sh
if [ "$(cat ${ERR_FILE})" = "ERR=1" ];then
echo "Build failed for image: 'XFCE', trying again at 00:00 MST" >> ${HTMLDIR}/${FILENAME}
rm ${ERR_FILE}
${0} -bl
else
echo "8/${TOTAL} completed at $(date +%T) " >> ${HTMLDIR}/${FILENAME}
fi
if [ ! -f sha256sums.txt ];then
echo "sha manifest does not exist!"
else
echo "Signing checksum file" >> ${HTMLDIR}/${FILENAME}
./sign-file.sh -f sha256sums.txt
mvImages
fi
echo "Done!"
return
}
genHtml(){
FILENAME="status.html"
echo "" > ${HTMLDIR}/${FILENAME}
echo "" >> ${HTMLDIR}/${FILENAME}
echo "" >> ${HTMLDIR}/${FILENAME}
echo '" >> ${HTMLDIR}/${FILENAME}
echo "" >> ${HTMLDIR}/${FILENAME}
echo "" >> ${HTMLDIR}/${FILENAME}
echo '' >> ${HTMLDIR}/${FILENAME}
echo "This page will refresh every 10 seconds
" >> ${HTMLDIR}/${FILENAME}
echo "Build process initiated at:
$(date +%R) MST ($(date -u +%R) UTC) on $(date +%D)" >> ${HTMLDIR}/${FILENAME}
echo "ETA: 2 hours from initiation time
" >> ${HTMLDIR}/${FILENAME}
echo 'System Specs
' >> ${HTMLDIR}/${FILENAME}
echo "CPU Cores: 1" >> ${HTMLDIR}/${FILENAME}
echo "Disk Size: $(df -h| tr -s ' ' $'\t' | grep vda1 | cut -f2)" >> ${HTMLDIR}/${FILENAME}
echo "Disk Space Used: $(df | tr -s ' ' $'\t' | grep vda1 | cut -f5)" >> ${HTMLDIR}/${FILENAME}
echo "Memory Size: $(free -m| tr -s ' ' $'\t' | grep Mem: | cut -f2) Mb" >> ${HTMLDIR}/${FILENAME}
echo "Memory Free: $(free -m| tr -s ' ' $'\t' | grep Mem: | cut -f4) Mb" >> ${HTMLDIR}/${FILENAME}
echo "Swap Size: $(free -m| tr -s ' ' $'\t' | grep Swap: | cut -f2) Mb" >> ${HTMLDIR}/${FILENAME}
echo "Swap Used: $(free -m| tr -s ' ' $'\t' | grep Swap: | cut -f3) Mb" >> ${HTMLDIR}/${FILENAME}
echo "Live Image Specs
" >> ${HTMLDIR}/${FILENAME}
echo "System
"
echo "Kernel Version: $(xbps-query -S linux| grep pkgver | sed 's/pkgver://') series" >> ${HTMLDIR}/${FILENAME}
echo "GlibC Version: $(xbps-query -S glibc| grep pkgver | sed 's/pkgver://')" >> ${HTMLDIR}/${FILENAME}
echo "AMDGPU Version: $(xbps-query -S xf86-video-amdgpu| grep pkgver | sed 's/pkgver://')" >> ${HTMLDIR}/${FILENAME}
echo "
" >> ${HTMLDIR}/${FILENAME}
#cat ${HTMLDIR}/${FILENAME}
echo "Status
" >> ${HTMLDIR}/${FILENAME}
runBuilds
echo "Disk Space Used: $(df | tr -s ' ' $'\t' | grep vda1 | cut -f5)" >> ${HTMLDIR}/${FILENAME}
echo "All images were completed at $(date +%R) MST ($(date -u +%R) UTC)" >> ${HTMLDIR}/${FILENAME}
echo "Next build round in 24 hours" >> ${HTMLDIR}/${FILENAME}
echo 'Return to landing page' >> ${HTMLDIR}/${FILENAME}
echo "" >> ${HTMLDIR}/${FILENAME}
echo "" >> ${HTMLDIR}/${FILENAME}
return
}
case ${1} in
-bl|--build-later)
while true;do
snooze -v genHtml
done
;;
-bn|--build-now)
while true;do
genHtml && snooze -v genHtml
done
;;
*)
echo -e "\nusage: ${0} [-bn, -bl]\n"
echo -e "\n-bn run builds now, snooze after\n"
echo -e "-bl snooze now, run builds after\n\n"
;;
esac