#!/bin/sh

TMP=/var/log/setup/tmp
if [ ! -d $TMP ]; then

mkdir -p $TMP
fi

while [ 0 ]; do

# Reset menu flag:
#rm -f $TMP/SeTQUICK



 dialog --backtitle "VectorLinux System Menu" --title "Vector Linux System Menu (version 0.2)" \
--menu \
"Welcome to Vector Linux's System menu. Use the cursor or [+] [-] keys \n\
 to navigate the menu. Press the [enter] key to make a selection."  18 76 7 \
"KEYMAP" "remap 'KEYBOARD'. The default is US English.........." \
"COMSET" "setup 'MOUSE' and 'MODEM' devices...................." \
"XSETUP" "setup 'X WINDOWS'. If you get stuck: CTRL+ALT+BS....." \
"XTEXT"  "setup 'X Windows'. If the GUI config didn't work....." \
"CDSET"  "setup 'CD-ROM' device. DVD, CD-R, CD-R/W, etc ......." \
"TIME"   "Set the PC to local or universal time zone..........." \
"LILO"   "setup 'LILO' the linux boot loader..................." \
"NETWORK" "setup 'NETWORK'.Settings and card configuration....." \
"GATEWAY" "Setup internal network GATEWAY configuration......." \
"PPPSET" "setup 'DIAL-UP'. PPP, ISP's phone number, etc........" \
"WVDIAL" "Alternative to PPPSET for connecting to an ISP......." \
"SRVMENU"  "Menu to add/remove services from boot time.........." \
"PCMCIA"  "Start PCMCIA service for laptop computers..........." \
"MODULES" "setup 'DRIVERS'. [F2] to save & [ESC] to exit........" \
"SOUND" "setup 'SOUND'. ISA pnp & PCIsound cards.............." \
"PRINTER"  "setup 'PRINTER'. Make the printer print............" \
"PKGTOOL"  "The Slackware package system......................" \
"PKGTOOL2"  "Slackware enhanced package functions............." \
"ADMIN"  "Add/delete or change password of users on the system." \
"EXIT"   "To quit system menu........................." 2> $TMP/hdset
 if [ $? = 1 -o $? = 255 ]; then
  rm -f $TMP/hdset $TMP/SeT*
 clear
  exit 0
 fi
 MAINSELECT="`cat $TMP/hdset`"
 rm $TMP/hdset

 # Start checking what to do. Some modules may reset MAINSELECT to run the
 # next item in line.

  if [ "$MAINSELECT" = "KEYMAP" ]; then
   /sbin/kmapset
  fi

  if [ "$MAINSELECT" = "COMSET" ]; then
   /sbin/comset
  fi

  if [ "$MAINSELECT" = "XSETUP" ]; then
  if [ -x /usr/X11R6/bin/sax ]; then
	/usr/X11R6/bin/sax
	else
   /sbin/xf4config
  fi
  fi
  if [ "$MAINSELECT" = "XTEXT" ]; then
   /usr/X11R6/bin/xf86config
  fi

  if [ "$MAINSELECT" = "CDSET" ]; then
   /sbin/cdset
  fi
  
  if [ "$MAINSELECT" = "TIME" ]; then
  /usr/sbin/timeconfig
  fi
  
  if [ "$MAINSELECT" = "LILO" ]; then
   /sbin/liloconfig
  fi
  
  if [ "$MAINSELECT" = "PKGTOOL" ]; then
  pkgtool
  fi
  
  if [ "$MAINSELECT" = "PKGTOOL2" ]; then
  pkgtool2
  fi

  
  if [ "$MAINSELECT" = "NETWORK" ]; then
   /sbin/netconfig
  fi
  if [ "$MAINSELECT" = "GATEWAY" ]; then
   /sbin/netset
  fi
  
  if [ "$MAINSELECT" = "PPPSET" ]; then
   /usr/sbin/pppsetup
  fi
  if [ "$MAINSELECT" = "WVDIAL" ]; then
  if [ ! $DISPLAY = "" ]; then
   rxvt -e /usr/bin/wvdialconf /etc/wvdial.conf
   if [ -f /etc/wvdial.conf ]; then
   setwvdial
   else
   echo "Sorry no modem was found can't continue"
   sleep 3
   
   fi
   else
   /usr/bin/wvdialconf /etc/wvdial.conf
   if [ -f /etc/wvdial.conf ]; then
   setwvdial
   else
   echo "Sorry no modem was found can't continue"
   sleep 3
   fi
   fi
  fi
   if [ "$MAINSELECT" = "PCMCIA" ]; then
   chmod +x /etc/rc.d/rc.pcmcia  
dialog --title "PCMCIA ACTIVATED" \
 --msgbox "PCMCIA services are nowactivated \
and will be available on your next boot of the system." 10 60
fi
	if [ "$MAINSELECT" = "SRVMENU" ]; then
	/sbin/srvmenu
	fi

  if [ "$MAINSELECT" = "MODULES" ]; then
  mcedit /etc/rc.d/rc.modules
  fi
  
  if [ "$MAINSELECT" = "PRINTER" ]; then
 if [ -x /usr/lib/apsfilter/SETUP ]; then
  /usr/lib/apsfilter/SETUP
  else
  dialog --title "PRINTER PKGS NOT INSTALLED" --msgbox "Printer setup cannot find the necessary printer \
  programs to setup the printer. There are three packages that \
  need to be installed. Apsfilt.tgz, ghostscr.tgz, and gsfonts.tgz \
  are the reguired packages. They can be found at ftp://ftp.ibiblio.org \
  /pub/Linux/distributions/vectorlinux/packages/office. Install them \
  using mc with the drop down menu activated by pressing the f2 key \
  or from the prompt type pkg filename.tgz. Then come back and try \
  printer setup again. Sorry for the inconvienence." 12 72
    
 fi
  fi
    if [ "$MAINSELECT" = "SOUND" ]; then
   /usr/sbin/sndconfig
  fi
  if [ "$MAINSELECT" = "ADMIN" ]; then
  clear
  echo  "Select to 'A'dd 'D'elete or change 'P'assword for a user ?"
  echo -n "Please choose an option? [a/d/p]: "
  read ans
  if [ $ans = "a" -o $ans = "A" ]; then
  adduser
  sleep 2
  fi
  if [ $ans = "p" -o $ans = "P" ]; then
  echo -n "Which user desires a password change ?: "
  read ans2
  passwd $ans2
  echo "$ans2 password change was successfull"
  sleep 2
  fi
  if [ $ans = "d" -o  $ans = "D" ]; then
  echo -n "Name of the user you wish to delete? : "
  read ans1
  userdel -r $ans1
  echo "OK $ans1 has been deleted from the system."
  sleep 2
  fi
  fi
  
  if [ "$MAINSELECT" = "EXIT" ]; then
  break
  fi
  done
  clear
   exit 0
