#!/bin/sh
#
#
NOMSGLABEL=YES
NOMSGSEVERITY=YES
MSGVERB=text:action:tag:
export NOMSGLABEL NOMSGSEVERITY MSGVERB

runpasswd() {
    dim="`xdpyinfo | awk ' /dimensions/ {print $2}' | grep '1024x768'`"
    if [ "$?" = 0 ]; then
        geom="80x40+190+102"
    font="-sgi-terminal-*-*-*--12-*"
    else
        geom="80x40+150+172"
        font="-sgi-terminal-*-*-*--17-*"
    fi

    tmpfile=/usr/tmp/passwdstatus$$

    /usr/sbin/xwsh -geom $geom -fn $font -xrm "XWsh.autoFork: off" -nomenu -noscrollbar \
            -e sh -c 'passwd ; echo $? > '$tmpfile

    retval=`cat $tmpfile`

    if [ $retval != 0 ]; then
        xconfirm -c -b "Accept" -t "Password not changed." -t "Please try again."
    else
        xconfirm -c -b "Accept" -t "You have changed your password." -t "You may log in now."
    fi
    rm $tmpfile
}

case $1 in
  changepw)
    xconfirm -c -b "Accept" -t "You need a password before you can log in."
    runpasswd;;

  expirepw)
    xconfirm -c -b "Accept" -t "Your password will expire soon" -t "Please run /etc/passwd ";;
  nologin)
    xconfirm -c -b "Accept" -t "Login prohibited" -t "Please contact your system administrator.";;
  maxtrys)
    xconfirm -c -b "Accept" -t "Too many unsuccessful login attempts." -t "Session will restart.";;
  notconsole)
    xconfirm -c -b "Accept" -t "Root login restricted." -t "Please use system console.";;
  changepwexpired)
    xconfirm -c -b "Accept" -t "Your passwd has expired." -t "You need to choose a new one."
    runpasswd;;
esac

