Files
LDS-Base/Install_LDS.sh
2022-06-27 19:20:05 +02:00

126 lines
3.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
#OS Detect
case $(grep -e "^ID=*" "/etc/os-release" |sed 's/ID=//g') in
*"alpine"*)
dist=alp;;
*"ubuntu"* | *"debian"* )
dist=deb;;
*)
"This distro is not (yet) supported"
exit;;
esac
#Git-repo
repo=https://git.bprieshof.nl/Tools/LDS-Base
branch=main
LDSIDREPO=https://git.bprieshof.nl/Tools/LDS-ImageDownloader.git
pkgs="ca-certificates dnsmasq lighttpd"
##Set if using LDS-ImageDownloader
while true; do
read -r -n 1 -p"Install LDS-ImageDownloader? [y/n]: " REPLY1
echo ""
case $REPLY1 in
[yY]) LDSID=true
while true; do
read -r -n 1 -p"Download Installers? [y/n]: " REPLY2
echo ""
case $REPLY2 in
[yY]) LDSIDdwni=true
break;;
[nN])LDSIDdwni=false
break;;
*) echo "invalid input"
esac
done
while true; do
read -r -n 1 -p"Download Tools? [y/n]: " REPLY3
echo ""
case $REPLY3 in
[yY]) LDSIDdwnt=true
break;;
[nN]) LDSIDdwnt=false
break;;
*) echo "invalid input"
esac
done
pkgs="$pkgs zstd cpio git"
case $dist in
alp)
pkgs="$pkgs bash cdrkit"
break;;
deb )
pkgs="$pkgs genisoimage wget unzip"
break;;
esac
break;;
[nN]) LDSID=false
break;;
*) echo "invalid input"
esac
done
## install packages
case $dist in
alp)
pkgs="$pkgs grep"
apk update
apk add $pkgs
rc-update add lighttpd
rc-update add dnsmasq;;
deb )
apt update
apt install -y $pkgs
systemctl enable lighttpd dnsmasq;;
esac
wget -O /tmp/LDS.tar.gz "$repo"/archive/"$branch".tar.gz
tar xzf /tmp/LDS.tar.gz C /tmp
#Configure (re)start services
mkdir -p /opt/LDS/tftp /opt/LDS/www
mv /tmp/LDS-Base/iPXE /opt/LDS/tftp
mv /tmp/LDS-Base/UpdateIP.sh /opt/LDS
mv /tmp/LDS-Base/dnsmasq.conf /etc/dnsmasq.conf
mv /tmp/LDS-Base/lighttpd.conf /etc/lighttpd/lighttpd.conf
#Set dnsmasq ip range
echo ""
echo ""
ip a
read -p "Please enter the name of the network inteface: " netIF
sed -i "/NetIF=/c\NetIF=$netIF" /opt/LDS/UpdateIP.sh
ipa=$(ip -4 addr show $netIF | grep -m 1 -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -E -o "([0-9]{1,3}[\.]){2}[0-9]{1,3}" |head -1 )
ipa="$ipa"".0"
sed -i '/dhcp-range/c\dhcp-range='"$ipa"',proxy' /etc/dnsmasq.conf
## install packages
case $dist in
alp)
service lighttpd stop
service dnsmasq stop
service lighttpd start
service dnsmasq start;;
deb )
systemctl stop lighttpd dnsmasq
systemctl start lighttpd dnsmasq;;
esac
#Install LDS-ImageDownloader
if $LDSID; then
#git clone $LDSIDREPO /opt/LDS/ImageDownloader
cd /opt/LDS/ImageDownloader/
ln -s /opt/LDS/ImageDownloader/LinuxInstallers-LID.ipxe /opt/LDS/tftp/iPXE/LinuxInstallers-LID.ipxe
sed -i '/set LDSIMenu/c\set LDSIMenu LinuxInstallers-LID.ipxe' /opt/LDS/tftp/iPXE/LDS.ipxe
if $LDSIDdwnt; then
sed -i -e 's/#item CloneZilla/item CloneZilla/g' -e 's/#item GParted/item GParted/g' -e 's/#item SystemRescueCD/item SystemRescueCD/g' /opt/LDS/tftp/iPXE/LDS.ipxe
$SHELL Download-AllTools.sh
fi
if $LDSIDdwni; then
$SHELL Download-AllInstallers.sh
fi
fi