#!/bin/sh
# @vasm: HWSET
# @level: root
# @description: activate various initialization 
# 
# (c) Kocil, 2003
# (c) VLocity Linux, 2003

vdir=$(dirname $0)
. $vdir/vasm-functions

check_root

INIT_DIR="/etc/rc.d"

###################################################
#INITS="pnp hotplug pcmcia acpi serial parallel wireless alsa tmpfs"
#INITS="pnp acpi serial parallel wireless alsa tmpfs"
INITS="pnp acpi serial parallel wireless alsa"


init_desc()
{
case $1 in
udev) 
  echo "Dynamic /dev naming for hotplug on kernel 2.6"
  ;;
tmpfs) 
  echo "On memory /tmp. Recommended if RAM>=196MB + SWAP>=256MB"
  ;;
pnp) 
  echo "ISA Plug and Play, should be enabled for a modern PC"
  ;;
#hotplug)
#  echo "Hotplug system (USB pendrive, digital camera, etc)"
#  ;;
#pcmcia)
#  echo "PCMCIA card, commonly on laptop (network, modem, etc)"
#  ;;
apm)
  echo "Advanced Power Management, useful for Laptop"
  ;;
acpi)
  echo "Power Management, useful for Laptop"
  ;;
alsa)
  echo "Advanced Linux Sound System"
  ;;
serial)
  echo "Serial port and modem"
  ;;
parallel)
  echo "Parallel port and printer"
  ;;
wireless)
  echo "Networking using radio or infrared"
  ;;
keymap)
  echo "Keyboard mapping"
  ;;
esac
}

###################################################
# return the service status for a runlevel
# $1 = init name
init_status()
{
   if [ -x /etc/rc.d/rc.$1 ]; then
        echo "on"
   else
        echo "off"
   fi
}

###################################################
select_init()
{
TITLE="HARDWARE INIT CONFIGURATOR"
TEXT="\n
These are boot time hardware initializations.
You may disable un-needed ones to speed up the system."
DIMENSION="20 76 10"

echo '$DCMD --backtitle "$BACKTITLE" --title "$TITLE" \' > $fmenu
echo '--checklist "$TEXT" $DIMENSION \' >> $fmenu

for RC in $INITS; do
  DESC=`init_desc $RC`
  STATE=`init_status $RC`
  echo $RC \"$DESC\" $STATE \\ >> $fmenu
done
echo ' 2> $freply ' >> $fmenu

. $fmenu || return $?

if [ "$CMD" = "" ]; then
  CHOICES=`cat $freply | sed -e 's/"//g'`
else
  CHOICES=`cat $freply | sed -e 's!/! !g'`
fi

for RC in $INITS; do
  if echo $CHOICES | grep -qw $RC; then
    chmod +x /etc/rc.d/rc.$RC  
  else
    chmod -x /etc/rc.d/rc.$RC   
  fi
done

return 0

}

########################################################
# MAIN PROGRAM
# echo "Service Configurator is starting ..."
select_init
clean_exit $?
