## don't activate some services
#rm -f $MOUNTDIR/etc/rcsysinit.d/{S35hdparm,S30loadmodules,S40swap}
#rm -f $MOUNTDIR/etc/rc*.d/{S12random,S13sysinit,S20network,S44acpid,S55sshd}
#rm -f $MOUNTDIR/etc/rc*.d/{K00splash,K01acpid,K90random,K96swap,K97network,K97udev,K98localnet}

# change inittab so it opens tty root shells instead of asking for login
#
echo "Forcing \`inittab' to open tty root shells with no login..."
sed -i 's,^\([1-3]\):.*,\1:2345:respawn:/sbin/mingetty --autologin root --noclear tty\1,' $MOUNTDIR/etc/inittab
sed -i '/^[4-6]:.*/d' $MOUNTDIR/etc/inittab

# make initramfs

LANG=${LANGUAGE}_${COUNTRY} chroot $MOUNTDIR dracut \
   --filesystems "ext3 ext4 unionfs squashfs isofs reiserfs reiser4" \
   --nomdadmconf --nolvmconf \
   /boot/initramfs-${KERNEL_MAJVER}${KERNEL_EXTRAVER}.img.gz \
   ${KERNEL_MAJVER}${KERNEL_EXTRAVER}

# configure isolinux boot loader
cat > $MOUNTDIR2/boot/isolinux/isolinux.cfg << _EOF
PROMPT 0
TIMEOUT 20
DEFAULT vesamenu.c32
MENU TITLE ${buildinfo} (${KERNEL_MAJVER}${KERNEL_EXTRAVER} kernel)
MENU BACKGROUND openmamba.png
MENU COLOR TITLE 1;32;49 #ff00993d #00000000 std

LABEL kms
MENU LABEL default
 kernel /boot/vmlinuz-${KERNEL_MAJVER}${KERNEL_EXTRAVER}
 append initrd=/boot/initrmfs-${KERNEL_MAJVER}${KERNEL_EXTRAVER}.img.gz root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} ro selinux=0 quiet splash vga=789
LABEL vga1024
MENU LABEL VGA 1024x768 (no modeset)
 kernel /boot/vmlinuz-${KERNEL_MAJVER}${KERNEL_EXTRAVER}
 append initrd=/boot/initrmfs-${KERNEL_MAJVER}${KERNEL_EXTRAVER}.img.gz root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} ro selinux=0 quiet splash vga=792 nomodeset
LABEL vga800
MENU LABEL VGA 800x600 (no modeset)
 kernel /boot/vmlinuz-${KERNEL_MAJVER}${KERNEL_EXTRAVER}
 append initrd=/boot/initrmfs-${KERNEL_MAJVER}${KERNEL_EXTRAVER}.img.gz root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} ro selinux=0 quiet splash vga=789 nomodeset
LABEL debug
MENU LABEL Debug mode
 kernel /boot/vmlinuz-${KERNEL_MAJVER}${KERNEL_EXTRAVER}
 append initrd=/boot/initrmfs-${KERNEL_MAJVER}${KERNEL_EXTRAVER}.img.gz root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} ro selinux=0 rddebug rdshell
MENU SEPARATOR
LABEL memtest
 MENU LABEL Memory test
 kernel memtest
MENU SEPARATOR
MENU SEPARATOR
LABEL -
 MENU LABEL $PRODUCT_NAME build:`date -R`
 MENU DISABLE
_EOF

# install isolinux binary
[ -e $MOUNTDIR/usr/share/syslinux/isolinux.bin ] && cp $MOUNTDIR/usr/share/syslinux/isolinux.bin $MOUNTDIR2/boot/isolinux/isolinux.bin ||
    { echo "Error: /usr/share/syslinux/isolinux.bin not found. Please install the syslinux package.";
      exit 1; }

# copy syslinux addons to final root /boot dir
cp $MOUNTDIR/usr/share/syslinux/vesamenu.c32 $MOUNTDIR2/boot/isolinux/

# install memtest
[ -e $MOUNTDIR/boot/memtest.bin ] && cp $MOUNTDIR/boot/memtest.bin $MOUNTDIR2/boot/isolinux/memtest ||
    { echo "Error: /boot/memtest.bin not found. Please install the memtest86 package.";
      exit 1; }

prelink

#echo "Performing binaries prelinking..."
#chroot $MOUNTDIR /bin/bash -c "PRELINK_NOINITCHECK=1 /etc/cron.daily/prelink"