#!/bin/sh

# First, determine our slackware kernel name:
for ELEMENT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
  if $(cat /proc/cmdline | cut -f $ELEMENT -d ' ' | grep -q SLACK_KERNEL) ; then
    SLACK_KERNEL=$(cat /proc/cmdline | cut -f $ELEMENT -d ' ' | cut -f 2 -d =)
  fi
done
unset ELEMENT

# Next, find the kernel's release version:
VERSION=$(uname -r | tr - _)

# If someone tries to install kernels from a CD that doesn't contain any,
# we'll give them one chance to find a disc that does.
swapdisks() {
  if [ -r /mnt/var/log/setup/tmp/SeTCDdev ]; then
    CDDEVICE=$(cat /mnt/var/log/setup/tmp/SeTCDdev)
  elif [ -r /tmp/SeTCDdev ]; then
    CDDEVICE=$(cat /tmp/SeTCDdev)
  else
    return 1
  fi
  umount $CDDEVICE 1> /dev/null 2> /dev/null
  eject -s $CDDEVICE
  dialog --title "REINSERT KERNEL DISC" --msgbox \
"Please reinsert the Slackware disc containing the collection \
of Linux kernels.  Usually this is disc number one (the disc \
that you boot from).  Once you've inserted the disc, hit ENTER \
to continue." \
8 61
  mount $CDDEVICE /var/log/mount 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    sleep 7
    mount $CDDEVICE /var/log/mount 1> /dev/null 2> /dev/null
      if [ ! $? = 0 ]; then
      sleep 11
      mount $CDDEVICE /var/log/mount 1> /dev/null 2> /dev/null
    fi
  fi
}

( cd boot
  if [ -r vmlinuz-huge-smp-$VERSION ]; then
    ln -sf vmlinuz-huge-smp-$VERSION vmlinuz
    ln -sf config-huge-smp-$VERSION config
    ln -sf System.map-huge-smp-$VERSION System.map
  fi
)

# and after all that hard work
