File: davpass

package info (click to toggle)
avfs 1.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,916 kB
  • sloc: ansic: 31,364; sh: 6,482; perl: 1,916; makefile: 351
file content (77 lines) | stat: -rwxr-xr-x 1,395 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/sh

usage () {
  echo "davpass [-r 'realm'] [-h hostname] [-u username] [-p passwd]" 1>&2
  exit 1
}

while [ $# -gt 0 ] ; do
  case "x$1" in
    x-r )
      realm="$2"; shift; continue
      ;;
    x-h )
      host="$2"; shift; continue
      ;;
    x-u )
      username="$2"; shift; continue
      ;;
    x-p )
      passwd="$2"; shift; continue
      ;;
    * )
      usage
      ;;
  esac
  shift
done

if test -r "$AVFSBASE/#avfsstat" ; then
  basedir="$AVFSBASE"
elif test -r "$HOME/.avfs/#avfsstat" ; then
  basedir="$HOME/.avfs"
elif test -r "/#avfsstat" ; then
  basedir=
elif test -r "/overlay/#avfsstat" ; then
  basedir=/overlay
else
  echo "AVFS not running" 1>&2
  exit 1
fi
    
ctrlc () {
  stty echo
  exit 127
}

if [ "${host:-//UNSET//}" = //UNSET// ] ; then
  printf "Hostname: "
  read host < /dev/tty
fi

if [ "${realm:-//UNSET//}" = //UNSET// ] ; then
  printf "Realm (hit enter for any realm): "
  read realm < /dev/tty
fi

if [ "${username:-//UNSET//}" = //UNSET// ] ; then
  printf "Username: "
  read username < /dev/tty
fi

if [ "${passwd:-//UNSET//}" = //UNSET// ] ; then
  printf "Password: "
  trap ctrlc 2 3 15
  stty -echo
  read passwd < /dev/tty
  stty echo
fi
echo

acct="$host@$realm"

if [ "$acct" = @ ] ; then usage; fi

echo $username | cp /dev/stdin $basedir/#dav_ctl:$acct/username
echo $passwd | cp /dev/stdin $basedir/#dav_ctl:$acct/password