source: locker/bin/signup-minimal @ 540

Last change on this file since 540 was 502, checked in by andersk, 16 years ago
Check for successful response from signup backend.
  • Property svn:executable set to *
File size: 2.9 KB
RevLine 
[127]1#!/bin/sh
2
3if [ "$initlname" = "" ]; then
4  if [ "$lname" = "" ]; then
5    initlname=0
6  else
7    initlname=1
8  fi
9fi
10
11if [ "$lname" = "" ]; then
12  if [ "$1" = "" ]; then
13    echo
[458]14    echo "Would you like to sign up:"
15    echo "1. Your personal Athena account"
16    echo "2. A locker that you control (a club, a course, etc)"
17    echo "If you do not understand this question, you should answer '1'."
[127]18    printf "Please enter either '1' or '2' (without quotes): "
19    read whofor
[458]20    if [ "$whofor" = 1 ]; then
[127]21        lname=$USER
22        lroot=$HOME
[458]23    elif [ "$whofor" = 2 ]; then
[127]24        echo
[458]25        echo "OK.  A locker of your choice that you control will be signed up."
26        echo "Please enter the name of the selected locker below."
[127]27        echo "(For the locker /mit/sipb, you would enter sipb)."
28        printf "Locker name: "
29        read lname
30        lroot="/mit/$lname"
31    else
32        echo
[458]33        echo "ERROR:"
34        echo "You must select either '1' or '2'."
[127]35        exit 1
36    fi
37  else
38    lname=$1
39  fi
40fi
41
[458]42attach "$lname" 2>/dev/null
[127]43
44if [ "$lname" != "$USER" ]; then
45  temp=$lname
46  lname=$USER
[458]47  . "/mit/scripts/bin$scriptsdev/signup-minimal"
[127]48  lname=$temp
49
[463]50  ans=`athrun scripts scripts-ssh "$USER" /usr/local/bin/admof "$lname" "$USER@ATHENA.MIT.EDU"` 
[127]51  if [ "$ans" != "yes" ]; then
52    echo
[458]53    echo "ERROR:"
54    echo "It appears as though you are not an administrator of the locker <$lname>."
55    echo "Try running \"fs sa /mit/$lname $USER all\" and starting over."
56    echo "Contact scripts@mit.edu if you are unable to solve the problem."
[502]57    exit 1
[127]58  fi
59fi
60
[458]61attach "$lname" 2>/dev/null
[127]62
63if [ ! -d "/mit/$lname" ]; then
64  echo
[458]65  echo "ERROR:"
66  echo "Cannot find locker <$lname>."
[502]67  exit 1
[127]68fi
69
[458]70ans=`fs la "/mit/$lname" | grep '^  system:a[nyuth]*user .*l'`
71if [ -z "$ans" ]; then
[184]72  echo
[458]73  echo "ERROR:"
74  echo "It appears as though the locker <$lname> is not listable by system:anyuser."
75  echo "You might want to run \"fs sa /mit/$lname system:anyuser l\""
76  echo "(that's a lowercase L rather than a one) and then try again."
77  echo "Contact scripts@mit.edu if you are unable to solve the problem."
[502]78  exit 1
[184]79fi
80
[458]81mkdir "/mit/$lname/.scripts-signup" 2>/dev/null
[127]82
83if [ ! -d "/mit/$lname/.scripts-signup" ]; then
84  echo
[458]85  echo "ERROR:"
86  echo "It appears as though you do not have write access to the locker <$lname>."
87  echo "Contact scripts@mit.edu if you are unable to solve the problem."
[502]88  exit 1
[127]89fi
90
[458]91if type wget >/dev/null 2>/dev/null; then
92  WGET=wget
93else
94  WGET="athrun gnu wget"
95fi
[127]96
[502]97ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/$lname"`
[458]98rmdir "/mit/$lname/.scripts-signup"
99
[502]100if [ "$ans" != "done" ] && [ "$ans" != "username already taken" ]; then
101  echo "ERROR:"
102  echo "Signup reported the following error: \"$ans\"."
103  echo "Contact scripts@mit.edu for assistance."
104  exit 1
105fi
106
[127]107success() {
108  if [ "$initlname" -eq 0 ]; then
109    echo
110    echo "== SUCCESS =="
[458]111    echo "$lname is now signed up for $1."
112    echo "$2"
[127]113    echo
114  fi
115}
Note: See TracBrowser for help on using the repository browser.