Skip to content

Commit

Permalink
whiptail interface, standalone mode...
Browse files Browse the repository at this point in the history
Signed-off-by: Florent CARLI <[email protected]>
  • Loading branch information
insatomcat committed Jun 11, 2024
1 parent 9fdacf8 commit cba5998
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ RUN echo "deb [arch=amd64] http://fai-project.org/download bookworm koeln" > /et
apt-get update && \
apt-get -y upgrade && \
apt-get -y install fai-server fai-doc fai-setup-storage && \
apt-get -y install lftp curl && \
apt-get -y install lftp curl whiptail && \
apt-get -y install qemu-utils && \
apt-get -y install reprepro xorriso squashfs-tools vim
82 changes: 81 additions & 1 deletion build_iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,86 @@ docker volume rm build_debian_iso_ext 2>/dev/null

set -ex

function addIndexToArray {
local -n myarray=$1
for idx in $(seq 1 $((${#myarray[@]}/2))); do
arrVar+=("$idx"")")
arrVar+=("${myarray[$(($idx*2-2))]}")
arrVar+=("${myarray[$(($idx*2-1))]}")
done
}

listClasses=("SEAPATH_DBG" "ON" "SEAPATH_COCKPIT" "ON" "SEAPATH_KERBEROS" "ON")
arrVar=()
echo ${listClasses[@]}
addIndexToArray listClasses
echo ${arrVar[@]}

CHOICES=$(whiptail --separate-output --checklist "Choose package classes to add to iso" 18 60 7 \
"${arrVar[@]}" 3>&1 1>&2 2>&3)
finalClasses=()
for CHOICE in $CHOICES; do
c=`echo $CHOICE | sed "s/)//"`
c=$((($c-1)*2))
echo ${listClasses[$c]}
finalClasses="$finalClasses""${listClasses[$c]}"","
done

addFlagCombination() {
listFlags=("french" "FRENCH rather than english" "ON" "dbg" "DEBUG packages" "OFF" "raid" "lvm RAID" "ON" "cockpit" "COCKPIT packages" "OFF" "kerberos" "KERBEROS packages" "OFF" "cluster" "CLUSTER rather than standalone" "ON")
arrVar=()
if CHOICES=$(whiptail --separate-output --checklist "Choose flags combination to add to grub" 18 60 7 "${listFlags[@]}" 3>&1 1>&2 2>&3); then
# code 0
finalFlags=()
if [ -z "$CHOICES" ]; then
finalFlags="noflag"
else
for CHOICE in $CHOICES; do
finalFlags="$finalFlags""${CHOICE}"","
done
finalFlags=${finalFlags::-1}
fi
menuItems+=("$finalFlags")
fi
}

menuItems=()

while [ 1 ]
do
menuItemsStr=""
for menuItem in ${menuItems[@]}; do
menuItemsStr="$menuItemsStr\n""$menuItem"
done
whiptail --msgbox "this is the list of grub menu entries:\ncluster,raid$menuItemsStr\n" 20 100
CHOICE=$(
whiptail --title "grub menu" --cancel-button "exit" --menu "Make your choice:" 22 100 14 \
"1)" "add grub entry (flag combinaison)" \
"2)" "continue" \
3>&2 2>&1 1>&3
)
[[ "$?" = 1 ]] && break

case $CHOICE in
"1)") addFlagCombination
;;
"2)") break
;;
esac
done

echo "" > /tmp/seapathlistfai.txt
for menuItem in ${menuItems[@]}; do
echo "menuentry \"SEAPATH installation - $menuItem\" {
search --set=root --file /FAI-CD
linux /boot/vmlinuz FAI_FLAGS="$menuItem,verbose,sshd,createvt,reboot" FAI_ACTION=install FAI_CONFIG_SRC=file:///var/lib/fai/config rd.live.image root=live:CDLABEL=FAI_CD ipv6.disable=1
initrd /boot/initrd.img
}" >> /tmp/seapathlistfai.txt
done

sed -i -ne '/## BEGIN CUSTOM MENU ITEMS/ {p; r /tmp/seapathlistfai.txt' -e ':a; n; /## END CUSTOM MENU ITEMS/ {p; b}; ba}; p' $wd/etc_fai/grub.cfg
rm -f /tmp/seapathlistfai.txt

# Creating the NFSROOT
# Removing *.profile since we don't use them
# Removing 50-host-classes to prevent DEMO and FAIBASE to be added to the list of classes
Expand Down Expand Up @@ -48,7 +128,7 @@ docker cp $wd/srv_fai_config/. fai-setup:/ext/srv/fai/config/
$COMPOSECMD -f $wd/docker-compose.yml down

# Creating the mirror
CLASSES="FAIBASE,DEBIAN,GRUB_EFI,SEAPATH_COMMON,SEAPATH_HOST,SEAPATH_DBG,SEAPATH_KERBEROS,SEAPATH_COCKPIT"
CLASSES="FAIBASE,DEBIAN,GRUB_EFI,SEAPATH_COMMON,${finalClasses[@]}LAST"
$COMPOSECMD -f $wd/docker-compose.yml run --rm fai-setup bash -c "\
cp /etc/fai/apt/keys/* /etc/apt/trusted.gpg.d/ &&\
fai-mirror -c $CLASSES /ext/mirror"
Expand Down
55 changes: 11 additions & 44 deletions etc_fai/grub.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## grub2 configuration
set default="SEAPATH installation - no raid, no kerberos, no debug tools"
set default="SEAPATH installation - Cluster mode with RAID, English, no kerberos, no debug tools"
set timeout=5

# make sure we can access partitions
Expand All @@ -14,59 +14,26 @@ set color_highlight=red/black
set menu_color_normal=white/black
set menu_color_highlight=black/yellow

menuentry " +------------------------------------------------------+" {
set timeout=20
}

menuentry " | Fully Automatic Installation |" {
set timeout=20

}
menuentry " | _VERSIONSTRING_ |" --unrestricted {
set timeout=20

}
menuentry " | (c) Thomas Lange [email protected] |" {
set timeout=20
}
menuentry " +------------------------------------------------------+" {
set timeout=20
}

menuentry "" {
set timeout=20
}

menuentry "SEAPATH installation - select installation type from menu" {
menuentry "SEAPATH installation - Cluster mode with RAID, English, no kerberos, no debug tools" {
search --set=root --file /FAI-CD
linux /boot/vmlinuz FAI_FLAGS="menu,verbose,sshd,createvt,reboot" FAI_ACTION=install FAI_CONFIG_SRC=file:///var/lib/fai/config rd.live.image root=live:CDLABEL=FAI_CD ipv6.disable=1 console=tty1
linux /boot/vmlinuz FAI_FLAGS="cluster,raid,verbose,sshd,createvt,reboot" FAI_ACTION=install FAI_CONFIG_SRC=file:///var/lib/fai/config rd.live.image root=live:CDLABEL=FAI_CD ipv6.disable=1 console=tty1
initrd /boot/initrd.img
}
menuentry "SEAPATH installation - no raid, no kerberos, no debug tools" {
search --set=root --file /FAI-CD
linux /boot/vmlinuz FAI_FLAGS="verbose,sshd,createvt,reboot" FAI_ACTION=install FAI_CONFIG_SRC=file:///var/lib/fai/config rd.live.image root=live:CDLABEL=FAI_CD ipv6.disable=1 console=tty1
initrd /boot/initrd.img
}
menuentry "SEAPATH installation - RAID, no kerberos, no debug tools" {
search --set=root --file /FAI-CD
linux /boot/vmlinuz FAI_FLAGS="raid,verbose,sshd,createvt,reboot" FAI_ACTION=install FAI_CONFIG_SRC=file:///var/lib/fai/config rd.live.image root=live:CDLABEL=FAI_CD ipv6.disable=1 console=tty1
initrd /boot/initrd.img
}
menuentry "SEAPATH installation - RAIDDEMO TTYS0, no kerberos, no debug tools" {
search --set=root --file /FAI-CD
linux /boot/vmlinuz FAI_FLAGS="raiddemo,verbose,sshd,createvt,reboot" FAI_ACTION=install FAI_CONFIG_SRC=file:///var/lib/fai/config rd.live.image root=live:CDLABEL=FAI_CD ipv6.disable=1 console=ttyS0
initrd /boot/initrd.img
}
menuentry "SEAPATH installation - no raid, KERBEROS, no debug tools" {

## BEGIN CUSTOM MENU ITEMS

menuentry "SEAPATH installation - french,raid,cluster" {
search --set=root --file /FAI-CD
linux /boot/vmlinuz FAI_FLAGS="kerberos,verbose,sshd,createvt,reboot" FAI_ACTION=install FAI_CONFIG_SRC=file:///var/lib/fai/config rd.live.image root=live:CDLABEL=FAI_CD ipv6.disable=1 console=tty1
linux /boot/vmlinuz FAI_FLAGS=french,raid,cluster,verbose,sshd,createvt,reboot FAI_ACTION=install FAI_CONFIG_SRC=file:///var/lib/fai/config rd.live.image root=live:CDLABEL=FAI_CD ipv6.disable=1
initrd /boot/initrd.img
}
menuentry "SEAPATH installation - no raid, no kerberos, DEBUG tools" {
menuentry "SEAPATH installation - noflag" {
search --set=root --file /FAI-CD
linux /boot/vmlinuz FAI_FLAGS="dbg,verbose,sshd,createvt,reboot" FAI_ACTION=install FAI_CONFIG_SRC=file:///var/lib/fai/config rd.live.image root=live:CDLABEL=FAI_CD ipv6.disable=1 console=tty1
linux /boot/vmlinuz FAI_FLAGS=noflag,verbose,sshd,createvt,reboot FAI_ACTION=install FAI_CONFIG_SRC=file:///var/lib/fai/config rd.live.image root=live:CDLABEL=FAI_CD ipv6.disable=1
initrd /boot/initrd.img
}
## END CUSTOM MENU ITEMS

menuentry "Boot OS from first partition on first disk" {
if [ "$grub_platform" = "efi" ]; then
Expand Down
5 changes: 4 additions & 1 deletion srv_fai_config/class/99-seapath
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# do not use this if a menu will be presented
[ "$flag_menu" ] && exit 0

echo DEBIAN FAIBASE FRENCH BOOKWORM64 SEAPATH_COMMON SEAPATH_HOST
echo DEBIAN FAIBASE BOOKWORM64 SEAPATH_COMMON SEAPATH_HOST

[ "$flag_french" ] && echo "FRENCH"
[ "$flag_cluster" ] && echo "SEAPATH_CLUSTER"
[ "$flag_raid" ] && echo "SEAPATH_RAID"
[ "$flag_raiddemo" ] && echo "SEAPATH_RAID SEAPATH_RAID_DEMO"
[ "$flag_dbg" ] && echo "SEAPATH_DBG"
[ "$flag_kerberos" ] && echo "SEAPATH_KERBEROS"
[ "$flag_cockpit" ] && echo "SEAPATH_COCKPIT"

exit 0
14 changes: 14 additions & 0 deletions srv_fai_config/package_config/SEAPATH_CLUSTER
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This packages are specific to Cluster Mode
PACKAGES install-norec
ceph
ceph-base
ceph-common
ceph-mgr
ceph-mon
ceph-osd
corosync
crmsh
libcephfs2
pacemaker
python3-ceph-argparse
python3-cephfs
14 changes: 1 addition & 13 deletions srv_fai_config/package_config/SEAPATH_HOST
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
# This packages are specific to the Host and should not be installed on the VM
# This packages are specific to the Host (Standalone or Cluster) and should not be installed on the VM
PACKAGES install-norec
busybox
ceph
ceph-base
ceph-common
ceph-mgr
ceph-mon
ceph-osd
corosync
crmsh
firmware-amd-graphics
firmware-misc-nonfree
firmware-linux-nonfree
firmware-linux-free
gunicorn
intel-cmt-cat
ipmitool
libcephfs2
libvirt-clients
libvirt-daemon
libvirt-daemon-driver-storage-rbd
Expand All @@ -26,9 +17,6 @@ msr-tools
nginx
ntfs-3g
openvswitch-switch
pacemaker
python3-ceph-argparse
python3-cephfs
python3-flaskext.wtf
python3-xmltodict
qemu-block-extra
Expand Down

0 comments on commit cba5998

Please sign in to comment.