#!/bin/sh
# @vasm : USER
# @level: user
# @description: setup password and users  
# 
# (c) Eko M. Budi, 2003
# (c) Vector Linux, 2003
#
# Released under GNU GPL

VDIR=$(dirname $0)

. $VDIR/vasm-functions

#########################################################################
menu_root()
{
  DIMENSION="19 70 4"
  [ "$CMD" ] && DIMENSION="21 70 4"
  TITLE="USER ADMINISTRATION"
  TEXT="\n
Linux is a secure system, thus every user must have\n
an account to login. The first and the most powerfull\n
account is called a 'root'. However, for security reason,\n
you should login as root only if necessary. This menu\n
allows you to register casual users for yourself, as well\n
as for other people.\n\n
Please select what do you want to do ?"

$DCMD --backtitle "$BACKTITLE" --title "$TITLE" --menu "$TEXT" $DIMENSION \
 "ADD"  "Add a new user" \
 "DEL"  "Delete some users" \
 "PASSWD"   "Change user password" \
 "PASSROOT" "Change root password" \
 2> $freply

   [ ! $? = 0 ] && clean_exit 1

    case `cat $freply` in
      PASSROOT)
        $VDIR/vpasswd root
        ;; 
      PASSWD) 
        $VDIR/vpasswd
        ;;
      ADD)
        $VDIR/vuseradd
        ;;
      DEL)
        $VDIR/vuserdel
	;;
    esac
}

####################################################################################
# MAIN PROGRAM

# Menu for root, or plain change password for user
if [ "$UID" = 0 ]; then
  while [ 1 ]; do 
    menu_root
  done
else
   exec $VDIR/vpasswd1 
fi
