source: locker/bin/signup-minimal @ 727

Last change on this file since 727 was 726, checked in by geofft, 16 years ago
Attach the locker before attempting to sign it up. (Previously it was only attached when running signup-* independently, rather than from deploy/bin/onathena.) This should fix the bug with non-automounting Athena machines not allowing group locker signups. There is some code from signup-minimal that is newer than the equivalent code in deploy/bin/onathena (e.g., the code path that runs attach "$lname" to ensure the locker is attachable); the common code should be refactored, or at least onathena should be synchronized.
  • Property svn:executable set to *
File size: 2.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=$USER
28        lroot=$HOME
29    elif [ "$whofor" = 2 ]; then
30        echo
31        echo "OK.  A locker of your choice that you control will be signed up."
32        echo "Please enter the name of the selected locker below."
33        echo "(For the locker /mit/sipb, you would enter sipb)."
34        while true; do
35            printf "Locker name: "
36            read lname
37            if attach "$lname"; then
38                break
39            fi
40            echo "$lname is not a valid locker name."
41        done
42        lroot="/mit/$lname"
43    else
44        echo
45        echo "ERROR:"
46        echo "You must select either '1' or '2'."
47        exit 1
48    fi
49  else
50    lname=$1
51  fi
52fi
53
54attach "$lname" 2>/dev/null
55
56ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/fsla.php/mit/$lname"`
57if [ "$ans" != "0" ]; then
58  echo
59  echo "ERROR:"
60  echo "The scripts servers cannot verify the permissions of the locker <$lname>."
61  echo "Try running \"fs sa /mit/$lname daemon.scripts l\" (with a lowercase"
62  echo "L at the end) and then try again. Contact scripts@mit.edu if you are"
63  echo "unable to solve the problem."
64  exit 1
65fi
66
67principal=`klist -5 | sed -n 's/^Default principal: // p'`
68ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/admof.php/$lname/$principal"`
69if [ "$ans" != "yes" ]; then
70  afsuser=`echo "$principal" | sed 's/@ATHENA.MIT.EDU$//'`
71  echo
72  echo "ERROR:"
73  echo "It appears as though you are not an administrator of the locker <$lname>."
74  echo "Try running \"fs sa /mit/$lname $afsuser all\" and starting over."
75  echo "Contact scripts@mit.edu if you are unable to solve the problem."
76  exit 1
77fi
78
79mkdir -p "/mit/$lname/.scripts-signup"
80
81if [ ! -d "/mit/$lname/.scripts-signup" ]; then
82  echo
83  echo "ERROR:"
84  echo "It appears as though you do not have write access to the locker <$lname>."
85  echo "Contact scripts@mit.edu if you are unable to solve the problem."
86  exit 1
87fi
88
89ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/$lname"`
90rmdir "/mit/$lname/.scripts-signup"
91
92if [ "$ans" != "done" ] && [ "$ans" != "username already taken" ]; then
93  echo "ERROR:"
94  echo "Signup reported the following error: \"$ans\"."
95  echo "Contact scripts@mit.edu for assistance."
96  exit 1
97fi
98
99success() {
100  if [ "$initlname" -eq 0 ]; then
101    echo
102    echo "== SUCCESS =="
103    echo "$lname is now signed up for $1."
104    echo "$2"
105    echo
106  fi
107}
Note: See TracBrowser for help on using the repository browser.