diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trac-digest.sh	Thu Jan 17 21:44:13 2008 +0200
@@ -0,0 +1,69 @@
+#!/bin/sh
+# -*- mode: utf8-unix -*-
+
+# In Public Domain.
+# mail:gavenko_a@3g.ua
+
+user=
+pass=
+status=
+
+while [ "$1" ]; do
+    case "$1" in
+        -h|-help|--help)
+            echo "Usage:"
+            echo " > $0 [--help] -u <user> -p <pass>"
+            echo "or with long options:"
+            echo " > $0 [--help] --user=<user> --password=<pass>"
+            exit 0
+            ;;
+        -u)
+            shift
+            if [ "$1" == "" ]; then
+                echo "Could not found username."
+                exit 1
+            else
+                user="$1"
+                status=o${status}
+            fi
+            ;;
+        "--user="*)
+            user=${1#--user=}
+            status=o${status}
+            ;;
+        -p)
+            shift
+            if [ "$1" == "" ]; then
+                echo "Could not found password."
+                exit 1
+            else
+                pass="$1"
+                status=${status}k
+            fi
+            ;;
+        "--password="*)
+            pass=${1#--password=}
+            status=${status}k
+            ;;
+        *)
+            echo "$1 unsuported options."
+            exit 1
+            ;;
+    esac
+
+    shift
+done
+
+if [ "$status" == "ok" ]; then
+    md=`echo -e "${user}:trac:${pass}\c" | md5sum --binary -`
+    md=${md% *-}
+
+    echo "${user}:trac:${md}"
+    exit 0
+else
+    echo "You give duplicate options. Try"
+    echo " > $0 --help"
+    exit 1
+fi
+
+