Change test order

This commit is contained in:
Adrien Reslinger 2020-04-12 23:34:41 +02:00
parent 983c7722cd
commit cc4d694c8e

View file

@ -43,17 +43,7 @@ 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 <<EOF
title CentOS 8 Install (PXE)
root (hd0,0)
kernel $PARTBOOT/vmlinuz ${INST_OPTIONS} inst.ks=http://boot.reslinger.net/ks8.cfg inst.stage2=$MIRROIR ${CONSOLE}
initrd $PARTBOOT/initrd.img
EOF
NB="$(grep -Ev '^($| *#)' /boot/grub/grub.conf | grep -c title)"
NB=$[$NB-1]
echo -e "savedefault --default=$NB --once\nquit\n" | grub --batch
elif [ -f /boot/grub2/grub.cfg ]; then
if [ -f /boot/grub2/grub.cfg ]; then
if [ $(sed 's/ /\n/g' /proc/cmdline | grep -c console) -gt 1 ]; then
# echo "On ajoute les console pour avoir une config également en serial"
CONSOLE="$(for i in `sed 's/ /\n/g' /proc/cmdline | grep console`; do echo -n "$i "; done | sed 's/ $//')"
@ -91,6 +81,16 @@ EOF
fi
grub2-mkconfig --output="${CONFDIR}"/grub.cfg
grub2-reboot 'CentOS 8 Install (PXE)'
elif [ -f /boot/grub/grub.conf ]; then
cat >> /boot/grub/grub.conf <<EOF
title CentOS 8 Install (PXE)
root (hd0,0)
kernel $PARTBOOT/vmlinuz ${INST_OPTIONS} inst.ks=http://boot.reslinger.net/ks8.cfg inst.stage2=$MIRROIR ${CONSOLE}
initrd $PARTBOOT/initrd.img
EOF
NB="$(grep -Ev '^($| *#)' /boot/grub/grub.conf | grep -c title)"
NB=$[$NB-1]
echo -e "savedefault --default=$NB --once\nquit\n" | grub --batch
else
echo "Bootloader non identifié !" >&2
exit 1