source: trunk/locker/bin/signup-minimal @ 1494

Last change on this file since 1494 was 1442, checked in by mitchb, 15 years ago
Deploy clarifications to the fascist locker signup error message (Merge of r1440:1441 from branches/locker-dev to trunk)
File size: 3.8 KB
Line 
1#!/bin/bash
2
3if [ "$initlname" = "" ]; then
4  if [ "$lname" = "" ]; then
5    initlname=0
6  else
7    initlname=1
8  fi
9fi
10
11if type wget >/dev/null 2>/dev/null; then
12  WGET=wget
13else
14  WGET="athrun gnu wget"
15fi
16
17if [ "$lname" = "" ]; then
18  if [ "$1" = "" ]; then
19    echo
20    echo "Would you like to sign up:"
21    echo "1. Your personal Athena account"
22    echo "2. A locker that you control (a club, a course, etc)"
23    echo "If you do not understand this question, you should answer '1'."
24    printf "Please enter either '1' or '2' (without quotes): "
25    read whofor
26    if [ "$whofor" = 1 ]; then
27        lname="${ATHENA_USER:-$USER}"
28    elif [ "$whofor" = 2 ]; then
29        echo
30        echo "OK.  A locker of your choice that you control will be signed up."
31        echo "Please enter the name of the selected locker below."
32        echo "(For the locker /mit/sipb, you would enter sipb)."
33        printf "Locker name: "
34        read lname
35    else
36        echo
37        echo "ERROR:"
38        echo "You must select either '1' or '2'."
39        exit 1
40    fi
41    while true; do
42        if attach "$lname"; then
43            break
44        fi
45        echo "$lname is not a valid locker name."
46        printf "Locker name: "
47        read lname
48    done
49  else
50    lname="$1"
51  fi
52fi
53lroot="/mit/$lname" 
54
55attach "$lname" 2>/dev/null
56
57ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/fsla.php/mit/$lname"`
58if [ "$ans" != "0" ]; then
59  echo
60  echo "ERROR:"
61  echo "The scripts servers cannot verify the permissions of the locker <$lname>."
62  echo "This is probably because your locker is not publicly listable."
63  echo "You can remedy this signup problem and make your locker publicly"
64  echo "listable by running \"fs setacl /mit/$lname system:anyuser l\""
65  echo "(that's a lowercase L at the end)."
66  echo ""
67  echo "NOTE: This will make it possible for the public (including anyone"
68  echo "viewing http://web.mit.edu/$lname) to see the names of your files"
69  echo "and the list of people who have access to them, though it will not"
70  echo "cause the contents of your files to be publicly readable.  If you"
71  echo "are unwilling to have your locker listable by the public, please"
72  echo "contact scripts@mit.edu for information about other ways to work"
73  echo "around the problem, or see http://scripts.mit.edu/faq/122 for more"
74  echo "detailed information."
75  exit 1
76fi
77
78principal=`klist -5 | sed -n 's/^Default principal: // p'`
79ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/admof.php/$lname/$principal"`
80if [ "$ans" != "yes" ]; then
81  afsuser=`echo "$principal" | sed 's/@ATHENA.MIT.EDU$//'`
82  echo
83  echo "ERROR:"
84  echo "It appears as though you are not an administrator of the locker <$lname>."
85  echo "Try running \"fs sa /mit/$lname $afsuser all\" and starting over."
86  echo "Contact scripts@mit.edu if you are unable to solve the problem."
87  exit 1
88fi
89
90mkdir -p "/mit/$lname/.scripts-signup"
91
92if [ ! -d "/mit/$lname/.scripts-signup" ]; then
93  echo
94  echo "ERROR:"
95  echo "It appears as though you do not have write access to the locker <$lname>."
96  echo "Contact scripts@mit.edu if you are unable to solve the problem."
97  exit 1
98fi
99
100ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/$lname"`
101rmdir "/mit/$lname/.scripts-signup"
102
103if [ "$ans" = "done" ]; then
104  # nscd caches account nonexistence with a 5-second TTL.
105  # (LDAP updates are more or less instant.)
106  # Somehow, the server can wait up to 10 seconds...
107  echo "Creating scripts.mit.edu account for $lname..."
108  sleep 10
109fi
110
111if [ "$ans" != "done" ] && [ "$ans" != "username already taken" ]; then
112  echo "ERROR:"
113  echo "Signup reported the following error: \"$ans\"."
114  echo "Contact scripts@mit.edu for assistance."
115  exit 1
116fi
117
118success() {
119  if [ "$initlname" -eq 0 ]; then
120    echo
121    echo "== SUCCESS =="
122    echo "$lname is now signed up for $1."
123    echo "$2"
124    echo
125  fi
126}
Note: See TracBrowser for help on using the repository browser.