source: trunk/misc/shell.sh @ 3578

Last change on this file since 3578 was 3578, checked in by Gregory Vincic, 13 years ago

shell.sh now veryfies that there is a user with the given login before changing password

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 743 bytes
Line 
1#!/bin/sh
2PS1="ProSE: "
3
4function help()
5{
6  echo "passwd USER    Change password of USER"
7}
8
9function hide()
10{
11  stty -echo
12}
13
14function unhide()
15{
16  stty echo
17}
18
19function passwd()
20{
21  uid=`mysql -b proteios -e "select id from Users where login='$1'"|sed s/id//g`
22  if [ -z $uid ] || [ "$uid" == "" ]; then
23    echo "No such user $1" >> /dev/stderr
24  else
25    hide
26    read -p "New $1 password: " p1; echo
27    read -p "Repeat $1 password: " p2; echo
28    unhide
29    echo 
30    if [ "$p1" == "$p2" ]; then
31      md5=`echo -n $p1 | md5sum | awk '{print $1}'`
32      mysql -b proteios -e "update Passwords set md5password='$md5' where id = $uid"
33      echo "$1 password changed"
34    else
35      echo "Failed: passwords do not match"   
36    fi
37  fi
38}
Note: See TracBrowser for help on using the repository browser.