mirror of
https://git.valherun.com/valherun/pxe_boot_alma.git
synced 2026-10-15 21:22:03 -04:00
- restructure boot/kickstarts/scripts/docs into homelab/ - docs: alma9->10 breaking changes, CIS hardening, kickstart changes - add find_cron_entries.sh helper and codex running memory notes Co-Authored-By: Claude Fable 5 <[email protected]>
250 lines
6.2 KiB
Bash
250 lines
6.2 KiB
Bash
#!/bin/bash
|
|
|
|
echo "Content-type: text/plain"
|
|
echo
|
|
|
|
if [ "${QUERY_STRING}" != "" -a -d "/export/KickStart/cfg/${QUERY_STRING}" ]; then
|
|
DIST=${QUERY_STRING}
|
|
KDIR="/export/KickStart/cfg/$DIST"
|
|
URL="http://10.1.1.1/KickStart/$DIST"
|
|
else
|
|
DIST="CentOS"
|
|
KDIR="/export/KickStart/cfg/default"
|
|
URL="http://10.1.1.1/KickStart/CentOS"
|
|
fi
|
|
echo "# Using config directory $KDIR"
|
|
|
|
# Load config vars
|
|
. $KDIR/ks.config
|
|
|
|
# Find who is Asking
|
|
MAC=`perl -ne 'if (/DHCPACK\s+on\s+$ENV{REMOTE_ADDR}\s+to\s+([\w\:]+)/) { print "$1\n";}' /var/log/messages |tail -1`
|
|
if [ "$MAC" = "" ] ; then
|
|
MAC=`arp -a $REMOTE_ADDR |cut -d ' ' -f 4`
|
|
fi
|
|
|
|
IGRELEASE=`cd /export/KickStart/iglass-releases; ls probe* | tail -1`
|
|
|
|
echo
|
|
echo "# IP=$REMOTE_ADDR"
|
|
echo "# MAC=$MAC"
|
|
echo "# QUERY_STRING=${QUERY_STRING}"
|
|
echo "# IGRELEASE=$IGRELEASE"
|
|
echo
|
|
|
|
echo "install"
|
|
echo
|
|
if [ $INTERACTIVE = "y" ]; then
|
|
echo "INTERACTIVE"
|
|
fi
|
|
|
|
echo "text"
|
|
|
|
echo "keyboard us"
|
|
|
|
if [ "$DIST" = "CentOS" -o "$DIST" = "CentOS-3.7" ]; then
|
|
echo "mouse genericps/2 --device psaux --emulthree"
|
|
fi
|
|
|
|
echo
|
|
echo "lang en_US"
|
|
#echo "lang en_US.UTF-8"
|
|
#echo "langsupport --default en_US.UTF-8 en_US.UTF-8"
|
|
|
|
echo
|
|
#echo "network --device eth0 --bootproto dhcp"
|
|
echo "network --device eth0 --bootproto dhcp --nodns --noipv6"
|
|
#echo "network --device eth0 --bootproto static --ip 192.168.177.80 --netmask 255.255.255.0 --gateway 192.168.177.254 --nameserver 192.168.176.2,192.168.177.2 --hostname iprobe017"
|
|
echo
|
|
|
|
echo "url --url $URL"
|
|
|
|
echo
|
|
#echo "xconfig --card \"ATI Mach64\" --videoram 8192 --hsync 31.5-37.9 --vsync 50-70 --resolution 800x600 --depth 24"
|
|
echo "xconfig"
|
|
echo
|
|
echo "rootpw --iscrypted $MD5PASS"
|
|
echo
|
|
echo "firstboot --disabled"
|
|
echo
|
|
|
|
if [ "$DIST" = "CentOS-5.1" ]; then
|
|
echo "bootloader --location=mbr --driveorder=sda,sdb --append=\"rhgb quiet\" --md5pass=$MD5PASS";
|
|
#echo "vnc --password=kickMe";
|
|
echo "logging --host 10.1.1.1 --level debug";
|
|
else
|
|
echo "langsupport --default en_US en_US"
|
|
echo "bootloader --location=mbr --md5pass=$MD5PASS"
|
|
fi
|
|
|
|
if [ "$FIREWALL" = "n" ]; then
|
|
echo "firewall --disabled"
|
|
elif [ "$FIREWALL" = "enabled" ]; then
|
|
echo "firewall --enabled --port=22:tcp, 1024:tcp, 5432:tcp, 5432:udp"
|
|
elif [ "$FIREWALL" != "" ]; then
|
|
echo "firewall --$FIREWALL"
|
|
fi
|
|
|
|
if [ "$SELINUX" = "n" ]; then
|
|
echo "selinux --disabled"
|
|
elif [ "$SELINUX" != "" ]; then
|
|
echo "selinux --$SELINUX"
|
|
fi
|
|
|
|
echo "authconfig --enableshadow --enablemd5"
|
|
|
|
if [ "$TZ" = "" ]; then
|
|
echo "timezone America/New_York"
|
|
else
|
|
echo "timezone $TZ"
|
|
fi
|
|
|
|
if [ "$REBOOT" = "y" ]; then
|
|
echo "reboot"
|
|
fi
|
|
echo
|
|
|
|
# Setup Disk Partitions
|
|
echo "## Disk Partition Information"
|
|
|
|
if [ "$DISKTYPE" = "prompt" ] ; then
|
|
|
|
echo "# Prompt for partiion setup"
|
|
|
|
elif [ "$DISKTYPE" = "hd" ] ; then
|
|
|
|
echo "clearpart --all"
|
|
echo 'part /boot --fstype ext3 --size=100 --ondisk=hda'
|
|
echo 'part swap --size=2048 --ondisk=hda'
|
|
echo 'part swap --size=2048 --ondisk=hda'
|
|
#echo 'part swap --size=2048 --ondisk=hda'
|
|
#echo 'part swap --size=2048 --ondisk=hda'
|
|
echo 'part / --fstype ext3 --size=1100 --grow --ondisk=hda'
|
|
|
|
elif [ "$DISKTYPE" = "one" ] ; then
|
|
|
|
echo "clearpart --all"
|
|
echo 'part /boot --fstype ext3 --size=100'
|
|
echo 'part swap --size=2048'
|
|
echo 'part swap --size=2048'
|
|
echo 'part / --fstype ext3 --size=1100 --grow'
|
|
|
|
elif [ "$DISKTYPE" = "hdc" ] ; then
|
|
|
|
echo "clearpart --all"
|
|
echo 'part /boot --fstype ext3 --size=100 --ondisk=hdc'
|
|
echo 'part swap --size=2048 --ondisk=hdc'
|
|
echo 'part swap --size=2048 --ondisk=hdc'
|
|
echo 'part swap --size=2048 --ondisk=hdc'
|
|
echo 'part swap --size=2048 --ondisk=hdc'
|
|
echo 'part / --fstype ext3 --size=1100 --grow --ondisk=hdc'
|
|
|
|
elif [ "$DISKTYPE" = "sd" ] ; then
|
|
|
|
echo "clearpart --all"
|
|
echo 'part /boot --fstype ext3 --size=100 --ondisk=sda'
|
|
echo 'part swap --size=2048 --ondisk=sda'
|
|
echo 'part swap --size=2048 --ondisk=sda'
|
|
echo 'part swap --size=2048 --ondisk=sda'
|
|
echo 'part swap --size=2048 --ondisk=sda'
|
|
echo 'part / --fstype ext3 --size=1100 --grow --ondisk=sda'
|
|
|
|
else
|
|
|
|
# Created in %pre
|
|
echo "%include /tmp/diskpart.cfg"
|
|
|
|
#echo 'clearpart --all'
|
|
|
|
#echo 'part /boot --fstype ext3 --size=100 --ondisk=sda'
|
|
#echo 'part pv.11 --size=1 --grow --ondisk=sda'
|
|
##echo 'part pv.21 --size=1 --grow --ondisk=sdb'
|
|
|
|
#echo 'volgroup vga pv.11'
|
|
##echo 'volgroup vgb pv.21'
|
|
|
|
#echo 'logvol swap --fstype swap --name=swapVol01 --vgname=vga --size=4096'
|
|
##echo 'logvol swap --fstype swap --name=swapVol02 --vgname=vgb --size=4096'
|
|
|
|
#echo 'logvol / --fstype ext3 --name=rootVol --vgname=vga --size=1 --grow'
|
|
##echo 'logvol /usr/local --fstype ext3 --name=localVol --vgname=vgb --size=1 --grow'
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
# List of packages to install
|
|
echo '%packages'
|
|
echo "# Packages from $KDIR/KS_Packages.cfg"
|
|
cat $KDIR/KS_Packages.cfg
|
|
|
|
FLOG="custom-`date +%F`.log"
|
|
|
|
echo
|
|
echo "%pre"
|
|
echo
|
|
|
|
|
|
if [ "$PRE" = "y" ]; then
|
|
# NOTE: You do not have perl in %pre
|
|
echo "chvt 3"
|
|
echo "PRELOG=/tmp/$FLOG"
|
|
echo
|
|
for i in $KDIR/ks.d/P* ; do
|
|
echo "echo '-- Starting $i' | tee -a \$PRELOG"
|
|
echo
|
|
perl -ne "s/\#DIST/${DIST}/g; s/\#LOG/2\>\&1 \| tee \-a \\\$PRELOG/; print" $i
|
|
echo
|
|
echo "echo '-- Done with $i' | tee -a \$PRELOG"
|
|
done
|
|
echo "chvt 1"
|
|
fi
|
|
|
|
# Install happens now
|
|
|
|
echo
|
|
echo "%post"
|
|
echo
|
|
if [ "$POST" = "y" ]; then
|
|
echo "chvt 3"
|
|
|
|
echo "LOG=/root/$FLOG"
|
|
echo "MAC=$MAC"
|
|
echo "DIST=$DIST"
|
|
echo "IGRELEASE=$IGRELEASE"
|
|
echo
|
|
echo "cat /tmp/$FLOG >> \$LOG"
|
|
echo
|
|
echo "echo 'MAC=\$MAC' | tee -a \$LOG"
|
|
echo "echo 'DIST=\$DIST' | tee -a \$LOG"
|
|
echo "echo 'IGRELEASE=\$IGRELEASE' | tee -a \$LOG"
|
|
echo
|
|
|
|
for i in $KDIR/ks.d/S* ; do
|
|
echo "echo '-- Starting $i' | tee -a \$LOG"
|
|
echo
|
|
perl -ne "s/\#DIST/${DIST}/g; s/\#LOG/2\>\&1 \| tee \-a \\\$LOG/; print" $i
|
|
echo
|
|
echo "echo '-- Done with $i' | tee -a \$LOG"
|
|
done
|
|
|
|
echo "chvt 1"
|
|
fi
|
|
|
|
echo
|
|
echo "%post --nochroot"
|
|
echo
|
|
if [ "$POSTNR" = "y" ]; then
|
|
echo "chvt 3"
|
|
echo "LOG=/mnt/sysimage/root/$FLOG"
|
|
echo
|
|
for i in $KDIR/ks.d/N* ; do
|
|
echo "echo '-- Starting $i' | tee -a \$LOG"
|
|
echo
|
|
cat $i
|
|
echo
|
|
echo "echo '-- Done with $i' | tee -a \$LOG"
|
|
done
|
|
echo "chvt 1"
|
|
fi
|