Update install_pxe.sh script
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
parent
18fb54315d
commit
7c88af5102
1 changed files with 67 additions and 60 deletions
|
|
@ -1,24 +1,27 @@
|
|||
#/bin/bash
|
||||
|
||||
for PARAM in "$@"; do
|
||||
case "$PARAM" in
|
||||
--version=*) DIST_VERSION="${PARAM/*=}" ;;
|
||||
--distrib=*) DISTRIB="${PARAM/*=}" ;;
|
||||
--static) STATIC=true ;;
|
||||
--help)
|
||||
echo "syntaxe: $0 [--help] [--static] [--version=7|8] [--distrib=CentOS|AlmaLinux]"
|
||||
esac
|
||||
case "$PARAM" in
|
||||
--version=*) DIST_VERSION="${PARAM/*=}" ;;
|
||||
--distrib=*) DISTRIB="${PARAM/*=}" ;;
|
||||
--static) STATIC=true ;;
|
||||
--help)
|
||||
echo "syntaxe: $0 [--help] [--static] [--version=7|8] [--distrib=RedHat|CentOS|AlmaLinux]"
|
||||
esac
|
||||
done
|
||||
if [ -z "${DIST_VERSION}" ]; then
|
||||
DIST_VERSION=8
|
||||
DIST_VERSION=8
|
||||
fi
|
||||
if [ -z "${DISTRIB}" ]; then
|
||||
DISTRIB="CentOS"
|
||||
DISTRIB="AlmaLinux"
|
||||
fi
|
||||
|
||||
|
||||
if ! which wget; then
|
||||
yum install -y wget
|
||||
yum install -y wget
|
||||
fi
|
||||
if ! which ipcalc; then
|
||||
yum install -y ipcalc
|
||||
fi
|
||||
|
||||
IF="$(ip route show | grep ^default | sed 's/.* dev \([^ ]*\) *.*/\1/' | sort -u)"
|
||||
|
|
@ -31,32 +34,36 @@ DNS="$(grep nameserver /etc/resolv.conf | grep -v 127.0.0.1 | awk '{printf $2","
|
|||
ARCH=$(uname -m | sed 's|i.86|i386|')
|
||||
|
||||
if [ "${DIST_VERSION}" == "8" ]; then
|
||||
#MIRROIR=http://lune.saacy.reslinger.net/repos/CentOS8/$ARCH/os
|
||||
if [ "$DISTRIB" == "CentOS" ]; then
|
||||
MIRROIR=http://mirror.centos.org/centos/8/BaseOS/$ARCH/os
|
||||
elif [ "$DISTRIB" == "AlmaLinux" ]; then
|
||||
MIRROIR=https://repo.almalinux.org/almalinux/8/BaseOS/x86_64/os
|
||||
fi
|
||||
#MIRROIR=http://lune.saacy.reslinger.net/repos/CentOS8/$ARCH/os
|
||||
if [ "$DISTRIB" == "CentOS" ]; then
|
||||
MIRROIR=http://mirror.centos.org/centos/8/BaseOS/$ARCH/os
|
||||
elif [ "$DISTRIB" == "RedHat" ]; then
|
||||
MIRROIR=https://boot.reslinger.net/repo/8/rhel
|
||||
# elif [ "$DISTRIB" == "OracleLinux" ]; then
|
||||
# MIRROIR=https://xxxx/8/BaseOS/x86_64/os
|
||||
elif [ "$DISTRIB" == "AlmaLinux" ]; then
|
||||
MIRROIR=https://repo.almalinux.org/almalinux/8/BaseOS/x86_64/os
|
||||
fi
|
||||
elif [ "${DIST_VERSION}" == "7" ]; then
|
||||
#MIRROIR=http://centos.mirrors.ovh.net/ftp.centos.org/7/os/$ARCH
|
||||
MIRROIR=http://mirror.centos.org/centos/7/os/$ARCH
|
||||
#MIRROIR=http://lune.saacy.reslinger.net/repos/CentOS7/$ARCH/os
|
||||
#MIRROIR=http://centos.mirrors.ovh.net/ftp.centos.org/7/os/$ARCH
|
||||
MIRROIR=http://mirror.centos.org/centos/7/os/$ARCH
|
||||
#MIRROIR=http://lune.saacy.reslinger.net/repos/CentOS7/$ARCH/os
|
||||
else
|
||||
echo "Version ${DIST_VERSION} non reconnue" >&2
|
||||
exit 1
|
||||
echo "Version ${DIST_VERSION} non reconnue" >&2
|
||||
exit 1
|
||||
fi
|
||||
#DESKTOP=desktop
|
||||
INST_OPTIONS="inst.lang=fr_FR inst.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
|
||||
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=""
|
||||
|
|
@ -66,33 +73,33 @@ 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}"
|
||||
INST_OPTIONS="ks.device=link ${INST_OPTIONS}"
|
||||
else
|
||||
INST_OPTIONS="ks.device=$MAC ${INST_OPTIONS}"
|
||||
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}"
|
||||
INST_OPTIONS="ip=$IP::$GW:$MASK:$(hostname -s):$IF:off:${DNS/,*} ${INST_OPTIONS}"
|
||||
fi
|
||||
if [ -f /boot/grub2/grub.cfg -o $(find /boot/efi/EFI -name grub.cfg | egrep -c '(almalinux|centos|redhat)') -gt 0 ]; 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/ $//')"
|
||||
# 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/ $//')"
|
||||
fi
|
||||
|
||||
#BOOT_DISK="$(df -hP /boot/ | awk '{print $1}' | tail -n1)"
|
||||
BOOT_DISK="$(mount | grep -e '\s'"`df -h /boot | tail -n1 | awk '{print $6}'`"'\s' | cut -f1 -d\ )"
|
||||
#BOOT_UUID="$(tune2fs -l ${BOOT_DISK} | grep UUID | awk '{print $3}')"
|
||||
BOOT_UUID="$(blkid ${BOOT_DISK} | sed 's/.*\sUUID="\([^ ]*\)".*/\1/')"
|
||||
if [ $(echo "${BOOT_DISK}" | grep -c /dev/md) -eq 1 ]; then
|
||||
# Pas forcement /dev/md2 !!!
|
||||
UUID_BOOT_DISK="mduuid/$(mdadm --detail ${BOOT_DISK} | grep UUID | awk '{print $3}' | sed 's/://g')"
|
||||
else
|
||||
#echo "UUID_BOOT_DISK non defini" >&2
|
||||
#exit 1
|
||||
UUID_BOOT_DISK="${BOOT_UUID}"
|
||||
fi
|
||||
#BOOT_DISK="$(df -hP /boot/ | awk '{print $1}' | tail -n1)"
|
||||
BOOT_DISK="$(mount | grep -e '\s'"`df -h /boot | tail -n1 | awk '{print $6}'`"'\s' | cut -f1 -d\ )"
|
||||
#BOOT_UUID="$(tune2fs -l ${BOOT_DISK} | grep UUID | awk '{print $3}')"
|
||||
BOOT_UUID="$(blkid ${BOOT_DISK} | sed 's/.*\sUUID="\([^ ]*\)".*/\1/')"
|
||||
if [ $(echo "${BOOT_DISK}" | grep -c /dev/md) -eq 1 ]; then
|
||||
# Pas forcement /dev/md2 !!!
|
||||
UUID_BOOT_DISK="mduuid/$(mdadm --detail ${BOOT_DISK} | grep UUID | awk '{print $3}' | sed 's/://g')"
|
||||
else
|
||||
#echo "UUID_BOOT_DISK non defini" >&2
|
||||
#exit 1
|
||||
UUID_BOOT_DISK="${BOOT_UUID}"
|
||||
fi
|
||||
|
||||
cat >> /etc/grub.d/40_custom <<EOF
|
||||
cat >> /etc/grub.d/40_custom <<EOF
|
||||
menuentry '$DISTRIB ${DIST_VERSION} Install (PXE)' --unrestricted {
|
||||
set root='${UUID_BOOT_DISK}'
|
||||
if [ x\$feature_platform_search_hint = xy ]; then
|
||||
|
|
@ -104,30 +111,30 @@ menuentry '$DISTRIB ${DIST_VERSION} Install (PXE)' --unrestricted {
|
|||
initrd $PARTBOOT/initrd.img
|
||||
}
|
||||
EOF
|
||||
if [ -d /sys/firmware/efi -a -e /boot/efi/EFI/redhat/grub.cfg ]; then
|
||||
if [ -d /sys/firmware/efi -a -e /boot/efi/EFI/redhat/grub.cfg ]; then
|
||||
CONFDIR=/boot/efi/EFI/redhat
|
||||
elif [ -d /sys/firmware/efi -a -e /boot/efi/EFI/almalinux/grub.cfg ]; then
|
||||
CONFDIR=/boot/efi/EFI/almalinux
|
||||
elif [ -d /sys/firmware/efi -a -e /boot/efi/EFI/centos/grub.cfg ]; then
|
||||
CONFDIR=/boot/efi/EFI/centos
|
||||
else
|
||||
CONFDIR=/boot/grub2
|
||||
fi
|
||||
grub2-mkconfig --output="${CONFDIR}"/grub.cfg
|
||||
grub2-reboot "$DISTRIB ${DIST_VERSION} Install (PXE)"
|
||||
CONFDIR=/boot/efi/EFI/centos
|
||||
else
|
||||
CONFDIR=/boot/grub2
|
||||
fi
|
||||
grub2-mkconfig --output="${CONFDIR}"/grub.cfg
|
||||
grub2-reboot "$DISTRIB ${DIST_VERSION} Install (PXE)"
|
||||
elif [ -f /boot/grub/grub.conf ]; then
|
||||
cat >> /boot/grub/grub.conf <<EOF
|
||||
cat >> /boot/grub/grub.conf <<EOF
|
||||
title $DISTRIB ${DIST_VERSION} Install (PXE)
|
||||
root (hd0,0)
|
||||
kernel $PARTBOOT/vmlinuz ${INST_OPTIONS} inst.ks=https://boot.reslinger.net/ks${DIST_VERSION}.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
|
||||
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
|
||||
echo "Bootloader non identifié !" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# avec tigervnc:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue