90 lines
3.1 KiB
Bash
90 lines
3.1 KiB
Bash
#!/bin/bash
|
|
#Check if config is in current directory
|
|
if [[ ! -f Locations.conf ]];then
|
|
echo "Location config not found, Please got to the Project directory"
|
|
exit 10
|
|
fi
|
|
|
|
#Check if runnning in bash, else restart script in bash
|
|
if [[ "$SHELL" != *"bash"* ]]; then
|
|
SHELL=/bin/bash
|
|
bash "$(basename $0)"
|
|
exit
|
|
fi
|
|
|
|
source Locations.conf
|
|
|
|
cat << EOF
|
|
#########################################################################################################
|
|
# Create PXE bootable Proxmox image including ISO #
|
|
# Make sure to install required packages: zstd genisoimage cpio #
|
|
# #
|
|
# Author: mrballcb @ Proxmox Forum (06-12-2012) #
|
|
# Thread: http://forum.proxmox.com/threads/8484-Proxmox-installation-via-PXE-solution?p=55985#post55985 #
|
|
# Modified: morph027 @ Proxmox Forum (23-02-2015) to work with 3.4 #
|
|
# Modified: brammp @ 24-06-2022 to download latest image for use with LDS #
|
|
#########################################################################################################
|
|
EOF
|
|
|
|
#Set folder vars
|
|
WorkDir=/opt/TMPLDSIDWD
|
|
TargetDir="$WWWStore/Installer/Proxmox"
|
|
#Check if folder exists
|
|
[ -d "$TargetDir" ] || mkdir -p "$TargetDir"
|
|
[ -d "$WorkDir" ] || mkdir -p "$WorkDir"
|
|
|
|
#Download latest version of Proxmox VE
|
|
wget -O "$WorkDir"/proxmox.iso $(wget -d -r -np -N -P "$WorkDir"/TmpDownload --spider -e robots=off http://download.proxmox.com/iso/ 2>&1 | grep " -> " | grep -Ev "\/\?C=" | sed "s/.* -> //" | grep "http[^\']*" | grep proxmox-ve | grep -v UTF-8 | tail -1)
|
|
|
|
##
|
|
pushd "$WorkDir" >/dev/null || exit 1
|
|
|
|
[ -L "proxmox.iso" ] && rm proxmox.iso &>/dev/null
|
|
|
|
for ISO in *.iso; do
|
|
if [ "$ISO" = "*.iso" ]; then continue; fi
|
|
if [ "$ISO" = "proxmox.iso" ]; then continue; fi
|
|
echo "Using ${ISO}..."
|
|
ln -s "$ISO" proxmox.iso
|
|
done
|
|
|
|
if [ ! -f "proxmox.iso" ]; then
|
|
echo "Couldn't find a proxmox iso, aborting."
|
|
echo "Add /path/to/iso_dir to the commandline."
|
|
exit 2
|
|
fi
|
|
|
|
[ -d pxeboot ] || mkdir pxeboot
|
|
|
|
pushd pxeboot >/dev/null || exit 1
|
|
echo "extracting kernel..."
|
|
isoinfo -i ../proxmox.iso -R -x /boot/linux26 > linux26 || exit 3
|
|
echo "extracting initrd..."
|
|
isoinfo -i ../proxmox.iso -R -x /boot/initrd.img > /tmp/initrd.img
|
|
mimetype="$(file --mime-type --brief /tmp/initrd.img)"
|
|
case "${mimetype##*/}" in
|
|
"zstd"|"x-zstd")
|
|
decompress="zstd -d /tmp/initrd.img -c"
|
|
;;
|
|
"gzip"|"x-gzip")
|
|
decompress="gzip -S img -d /tmp/initrd.img -c"
|
|
;;
|
|
*)
|
|
echo "unable to detect initrd compression method, exiting"
|
|
exit 1
|
|
;;
|
|
esac
|
|
$decompress > initrd || exit 4
|
|
echo "adding iso file ..."
|
|
echo "../proxmox.iso" | cpio -L -H newc -o >> initrd || exit 5
|
|
popd >/dev/null 2>&1 || exit 1
|
|
|
|
#echo "Finished! pxeboot files can be found in ${PWD}."
|
|
popd >/dev/null 2>&1 || true # don't care if these pops fail
|
|
popd >/dev/null 2>&1 || true
|
|
##
|
|
|
|
echo "Finished! Proxmox pxeboot files are added to LDS."
|
|
mv "$WorkDir"/pxeboot/* "$TargetDir"
|
|
rm -rf "$WorkDir"
|