#!/bin/sh
dialog --backtitle "Vector Linux Software LTD." \
	--title "SERVICES MENU" \
        --checklist "Hi, this is the service selection menu. You can use this to \n\
select a startup service which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following services are to start at boot time ?" 20 78 7 \
log  "The system and kernel loggers. Should be left on." on \
xfstt    "TrueType font server for X. Not needed for XFree 4." Off \
cron "schedule computer activities at delegated times." off \
inet    "Activates inet services as described in /etc/inetd.conf" on \
sendmail  "Starts the sendmail daemon." Off \
firewall  "Activates ip forwarding and a basic firewall" off \
gpm  "Starts console mouse daemon." off \
at  "Automatic schedule daemon." off \
rpc  "Sun portmap services." off \
dhcpd  "Supply dhcp services to your network." off \
hotplug  "Enable hot plugging of USB devices." off \
sshd  "Activate  the secure shell daemon." off \
portsentry  "Protect ports from outside attack." off \
lp  " Starts line printer daemon." on 2> /tmp/menu

retval=$?
nochoice=`ls /etc/rc.d/init.d`
choice=`cat /tmp/menu | sed -n 's/"//g p'`
rm -f /tmp/menu
sleep 1
case $retval in
  0)
    cd /etc/rc.d/init.d
    chmod -x *
    for i in $choice; do
    chmod +x $i
    done
    for n in $nochoice; do
    if [ $? `grep -q $n $choice` == 1 ]; then
    chmod -x $n
    fi
    done
    ;;
  1)
        clear
    exit 0
    ;;
  255)
    clear && exit 0
    ;;
esac
sleep 1
dialog --title "Services activated" --msgbox "The selections: '$choice' \n\
have been activated. \n\
They will start on your next boot." 10 62
clear
exit 0
