#!/bin/sh
# VASM
# VLocity Linux System Menu
# 
# (c) VLocity Linux, 2003


## Special service as super VASM
if [ "$1" = "--super-vasm" ]; then
   export PATH="$PATH:/sbin:/usr/sbin:/usr/X11R6/bin:/usr/bin:/usr/bin"
fi

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

dbug_start

menu_root()
{
 $DCMD --backtitle "$BACKTITLE" --title "VASM" \
--menu \
"\n
Welcome to VLocity Linux's Administration & System Menu.\n\n
Use the cursor [up] [down] keys to navigate the menu.\n
Press the [enter] key to make a selection."  20 71 8 \
"AUTOSETUP"  "autosetup hardware, network and GUI" \
"USER"       "manage the users on the system" \
"XWINDOW"    "setup X-Window GUI system" \
"SERVICE"    "setup services and boot procedures" \
"NETWORK"    "setup hostname and networking" \
"HARDWARE"   "setup keyboard, mouse, cdrom, sound, etc." \
"FILESYSTEM" "setup mount points, LILO and harddisk" \
"EXIT"       "Bye, see ya later" \
 2> $freply

  if [ $? != 0 ]; then
     clean_exit $?
  fi

  MAINSELECT="`cat $freply`"

  case "$MAINSELECT" in
  "AUTOSETUP")
    $vdir/vlautosetup
    ;;
  "USER"|"ADMIN")
    $vdir/vuser
    ;;
  "HARDWARE")
    $vdir/vhwmenu
    ;;
  "NETWORK")
    $vdir/vnetmenu
    ;;
  "GUI"|"XWINDOW")
    $vdir/vxmenu
    ;;
  "SERVICE")
    $vdir/vsrvmenu
    ;;
  "FILESYSTEM")
    $vdir/vfsmenu
    ;;
  "LILO")
    $vdir/vliloconf
    ;;
  "EXIT")
    clean_exit 0
    ;;
  esac
}


menu_user()
{
 $DCMD --backtitle "$BACKTITLE" --title "VASM (user mode)" \
--menu \
"\n
Welcome to VLocity Linux's Administration & System Menu.\n
This is a user mode VASM. More menu will be available\n
if you run super vasm as root\n\n
Use the cursor [up] [down] keys to navigate the menu.\n
Press the [enter] key to make a selection."  20 70 5 \
"PASSWD"    "change your password" \
"XWMSET"    "setup default window manager" \
"SKEL" "reset default settings" \
"SUPER" "run super VASM (root password is required)" \
"EXIT" "Bye, see you later" \
 2> $freply

  if [ $? != 0 ]; then
     clean_exit $?
  fi

  MAINSELECT="`cat $freply`"

  case "$MAINSELECT" in
  "PASSWD")
    $vdir/vpasswd
    ;;
  "XWMSET")
    $vdir/vxwmset
    ;;
  "SKEL")
    $vdir/vskel
    ;;
  "SUPER")
    exec $vdir/vsuper "Super-VASM" "$0 --super-vasm"
    ;;
  "EXIT")
    clean_exit 0
    ;;
  esac
}

while [ 0 ]; do
  if [ $UID = 0 ]; then
    menu_root
  else
    menu_user
  fi
done

clean_exit 0

