comparison trac-digest.sh @ 0:b78e329514b8

Add utils proj.
author Oleksander Gavenko <gavenko_a@3g.ua>
date Thu, 17 Jan 2008 21:44:13 +0200
parents
children b73ad8a02942
comparison
equal deleted inserted replaced
-1:000000000000 0:b78e329514b8
1 #!/bin/sh
2 # -*- mode: utf8-unix -*-
3
4 # In Public Domain.
5 # mail:gavenko_a@3g.ua
6
7 user=
8 pass=
9 status=
10
11 while [ "$1" ]; do
12 case "$1" in
13 -h|-help|--help)
14 echo "Usage:"
15 echo " > $0 [--help] -u <user> -p <pass>"
16 echo "or with long options:"
17 echo " > $0 [--help] --user=<user> --password=<pass>"
18 exit 0
19 ;;
20 -u)
21 shift
22 if [ "$1" == "" ]; then
23 echo "Could not found username."
24 exit 1
25 else
26 user="$1"
27 status=o${status}
28 fi
29 ;;
30 "--user="*)
31 user=${1#--user=}
32 status=o${status}
33 ;;
34 -p)
35 shift
36 if [ "$1" == "" ]; then
37 echo "Could not found password."
38 exit 1
39 else
40 pass="$1"
41 status=${status}k
42 fi
43 ;;
44 "--password="*)
45 pass=${1#--password=}
46 status=${status}k
47 ;;
48 *)
49 echo "$1 unsuported options."
50 exit 1
51 ;;
52 esac
53
54 shift
55 done
56
57 if [ "$status" == "ok" ]; then
58 md=`echo -e "${user}:trac:${pass}\c" | md5sum --binary -`
59 md=${md% *-}
60
61 echo "${user}:trac:${md}"
62 exit 0
63 else
64 echo "You give duplicate options. Try"
65 echo " > $0 --help"
66 exit 1
67 fi
68
69