From 983c7722cdac487f437d56f0fb4e5916e019aea4 Mon Sep 17 00:00:00 2001 From: Adrien Date: Sun, 12 Apr 2020 12:18:54 +0200 Subject: [PATCH] Add install-pxe script for CentOS 8 --- files/usr/local/sbin/install_pxe_CentOS7.sh | 0 files/usr/local/sbin/install_pxe_CentOS8.sh | 100 ++++++++++++++++++++ 2 files changed, 100 insertions(+) mode change 100644 => 100755 files/usr/local/sbin/install_pxe_CentOS7.sh create mode 100755 files/usr/local/sbin/install_pxe_CentOS8.sh diff --git a/files/usr/local/sbin/install_pxe_CentOS7.sh b/files/usr/local/sbin/install_pxe_CentOS7.sh old mode 100644 new mode 100755 diff --git a/files/usr/local/sbin/install_pxe_CentOS8.sh b/files/usr/local/sbin/install_pxe_CentOS8.sh new file mode 100755 index 0000000..c2d6643 --- /dev/null +++ b/files/usr/local/sbin/install_pxe_CentOS8.sh @@ -0,0 +1,100 @@ +#/bin/bash + +if ! which wget; then + yum install -y wget +fi + +IF="$(ip route show | grep ^default | sed 's/.* dev \([^ ]*\) *.*/\1/' | sort -u)" +IP="$(ip addr show $IF | grep inet\ | awk '{print $2}' | cut -d/ -f1)" +PREFIX="$(ip addr show $IF | grep inet\ | awk '{print $2}' | cut -d/ -f2)" +MASK="$(ipcalc -m $IP/$PREFIX | cut -d= -f2)" +GW="$(ip route show | grep ^default | sed 's/.* via \([^ ]*\) *.*/\1/' | sort -u)" +MAC="$(ip addr show $IF | grep ether\ | awk '{print $2}' | cut -d/ -f2 | tr [A-Z] [a-z])" +DNS="$(grep nameserver /etc/resolv.conf | grep -v 127.0.0.1 | awk '{printf $2","}' | sed 's/,$//')" +ARCH=$(uname -m | sed 's|i.86|i386|') + +MIRROIR=http://mirror.centos.org/centos/8/BaseOS/$ARCH/os +#MIRROIR=http://lune.saacy.reslinger.net/repos/CentOS8/$ARCH/os +#DESKTOP=desktop +INST_OPTIONS="lang=fr_FR keymap=fr-latin9 panic=1 ks.sendsn ks.sendmac inst.sshd=1 net.ifnames=0 biosdevname=0 $DESKTOP" +INST_OPTIONS="${INST_OPTIONS} inst.vnc inst.vncpassword=SDFGHJKL" +if [ -z "$DNS" ]; then + if [ $(whois $IP | grep -ci dedibox) -gt 0 ]; then + # Dedibox + DNS=62.210.16.6,62.210.16.7 + else + # OVH + DNS=213.186.33.99 + #DNS=46.246.46.46,194.132.32.23 + fi +fi +if [ $(mount | grep -c /boot\ ) -eq 1 ]; then + PARTBOOT="" +else + PARTBOOT="/boot" +fi +cd /boot +wget "$MIRROIR"/isolinux/{vmlinuz,initrd.img} +if [ $(ip link show | grep ^[0-9] | grep -v lo: | wc -l) -eq 1 ]; then + INST_OPTIONS="ks.device=link ${INST_OPTIONS}" +else + INST_OPTIONS="ks.device=$MAC ${INST_OPTIONS}" +fi +if [ ! -z "$STATIC" ]; then + INST_OPTIONS="ip=$IP::$GW:$MASK:$(hostname -s):$IF:off:${DNS/,*} ${INST_OPTIONS}" +fi +if [ -f /boot/grub/grub.conf ]; then + cat >> /boot/grub/grub.conf <&2 + #exit 1 + UUID_BOOT_DISK="${BOOT_UUID}" + fi + + cat >> /etc/grub.d/40_custom <&2 + exit 1 +fi + +# avec tigervnc: +# vncviewer CompressLevel 9 FullColor 176.31.103.156:1