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

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