| 1 |
#! /bin/sh |
| 2 |
|
| 3 |
usage () { |
| 4 |
echo "davpass [-r 'realm'] [-h hostname] [-u username] [-p passwd]" 1>&2 |
| 5 |
exit 1 |
| 6 |
} |
| 7 |
|
| 8 |
while [ $# -gt 0 ] ; do |
| 9 |
case "x$1" in |
| 10 |
x-r ) |
| 11 |
realm="$2"; shift; continue |
| 12 |
;; |
| 13 |
x-h ) |
| 14 |
host="$2"; shift; continue |
| 15 |
;; |
| 16 |
x-u ) |
| 17 |
username="$2"; shift; continue |
| 18 |
;; |
| 19 |
x-p ) |
| 20 |
passwd="$2"; shift; continue |
| 21 |
;; |
| 22 |
* ) |
| 23 |
usage |
| 24 |
;; |
| 25 |
esac |
| 26 |
shift |
| 27 |
done |
| 28 |
|
| 29 |
if test -r "$AVFSBASE/#avfsstat" ; then |
| 30 |
basedir="$AVFSBASE" |
| 31 |
elif test -r "$HOME/.avfs/#avfsstat" ; then |
| 32 |
basedir="$HOME/.avfs" |
| 33 |
elif test -r "/#avfsstat" ; then |
| 34 |
basedir= |
| 35 |
elif test -r "/overlay/#avfsstat" ; then |
| 36 |
basedir=/overlay |
| 37 |
else |
| 38 |
echo "AVFS not running" 1>&2 |
| 39 |
exit 1 |
| 40 |
fi |
| 41 |
|
| 42 |
ctrlc () { |
| 43 |
stty echo |
| 44 |
exit 127 |
| 45 |
} |
| 46 |
|
| 47 |
if [ "${host:-//UNSET//}" = //UNSET// ] ; then |
| 48 |
printf "Hostname: " |
| 49 |
read host < /dev/tty |
| 50 |
fi |
| 51 |
|
| 52 |
if [ "${realm:-//UNSET//}" = //UNSET// ] ; then |
| 53 |
printf "Realm (hit enter for any realm): " |
| 54 |
read realm < /dev/tty |
| 55 |
fi |
| 56 |
|
| 57 |
if [ "${username:-//UNSET//}" = //UNSET// ] ; then |
| 58 |
printf "Username: " |
| 59 |
read username < /dev/tty |
| 60 |
fi |
| 61 |
|
| 62 |
if [ "${passwd:-//UNSET//}" = //UNSET// ] ; then |
| 63 |
printf "Password: " |
| 64 |
trap ctrlc 2 3 15 |
| 65 |
stty -echo |
| 66 |
read passwd < /dev/tty |
| 67 |
stty echo |
| 68 |
fi |
| 69 |
echo |
| 70 |
|
| 71 |
acct="$host@$realm" |
| 72 |
|
| 73 |
if [ "$acct" = @ ] ; then usage; fi |
| 74 |
|
| 75 |
echo $username | cp /dev/stdin $basedir/#dav_ctl:$acct/username |
| 76 |
echo $passwd | cp /dev/stdin $basedir/#dav_ctl:$acct/password |
| 77 |
|