#!/bin/sh
#Function:administrator login
#Writer:liutiansi
#Mail:lliutiansi@gmail.com
#Date:2007-10-27 16:25

source config
go_tempfile=`go_tempfile 2>/dev/null` || go_tempfile=/tmp/login$$
trap "rm -f $go_tempfile" 0 1 2 5 15

dialog --title "$system_info" --clear \
	--insecure \
    --passwordbox "
请输入管理员密码：" 10 50 2> $go_tempfile

go_retval=$?

case $go_retval in
  0)
    go_mysql_result=`$mysql_bin -h $mysql_host -u$mysql_user -p$mysql_passwd -e "select * from sysadmin.ty_system_passwd;" | awk 'NR>1 {print NR,$0}'|awk '{print $2}'`
	go_passwd=`cat $go_tempfile`
	go_encrypt=`$sysadmin_path/bin/encrypt "$go_passwd"`
	if [ "$go_mysql_result" -eq "$go_encrypt" ]; then
		export go_encrypt
		rm -f $go_tempfile
		main
	else
		outmessage="对不起，你输入的密码不正确！"
		export outmessage
		msgbox
		go
	fi
	;;
  255)
    if test -s $go_tempfile ; then
      cat $go_tempfile
    else
      echo "取消登录！"
    fi
    ;;
esac
