source: locker/bin/signup-minimal @ 629

Last change on this file since 629 was 629, checked in by geofft, 16 years ago
Give an error message if admof is about to fail because scripts cannot run fs la. We should no longer need the lower check for system:anyuser l. Resolves [help.mit.edu #564492].
  • Property svn:executable set to *
File size: 2.8 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
[575]11if type wget >/dev/null 2>/dev/null; then
12  WGET=wget
13else
14  WGET="athrun gnu wget"
15fi
16
[127]17if [ "$lname" = "" ]; then
18  if [ "$1" = "" ]; then
19    echo
[458]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'."
[127]24    printf "Please enter either '1' or '2' (without quotes): "
25    read whofor
[458]26    if [ "$whofor" = 1 ]; then
[127]27        lname=$USER
28        lroot=$HOME
[458]29    elif [ "$whofor" = 2 ]; then
[127]30        echo
[458]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."
[127]33        echo "(For the locker /mit/sipb, you would enter sipb)."
34        printf "Locker name: "
35        read lname
36        lroot="/mit/$lname"
37    else
38        echo
[458]39        echo "ERROR:"
40        echo "You must select either '1' or '2'."
[127]41        exit 1
42    fi
43  else
44    lname=$1
45  fi
46fi
47
[458]48attach "$lname" 2>/dev/null
[127]49
50if [ ! -d "/mit/$lname" ]; then
51  echo
[458]52  echo "ERROR:"
53  echo "Cannot find locker <$lname>."
[502]54  exit 1
[127]55fi
56
[629]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 "Try running \"fs sa /mit/$lname daemon.scripts l\" (with a lowercase"
63  echo "L at the end) and then try again. Contact scripts@mit.edu if you are"
64  echo "unable to solve the problem."
65  exit 1
66fi
67
[576]68principal=`klist -5 | sed -n 's/^Default principal: // p'`
69ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/admof.php/$lname/$principal"`
70if [ "$ans" != "yes" ]; then
71  afsuser=`echo "$principal" | sed 's/@ATHENA.MIT.EDU$//'`
72  echo
73  echo "ERROR:"
74  echo "It appears as though you are not an administrator of the locker <$lname>."
75  echo "Try running \"fs sa /mit/$lname $afsuser all\" and starting over."
76  echo "Contact scripts@mit.edu if you are unable to solve the problem."
77  exit 1
78fi
79
[458]80mkdir "/mit/$lname/.scripts-signup" 2>/dev/null
[127]81
82if [ ! -d "/mit/$lname/.scripts-signup" ]; then
83  echo
[458]84  echo "ERROR:"
85  echo "It appears as though you do not have write access to the locker <$lname>."
86  echo "Contact scripts@mit.edu if you are unable to solve the problem."
[502]87  exit 1
[127]88fi
89
[502]90ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/$lname"`
[458]91rmdir "/mit/$lname/.scripts-signup"
92
[502]93if [ "$ans" != "done" ] && [ "$ans" != "username already taken" ]; then
94  echo "ERROR:"
95  echo "Signup reported the following error: \"$ans\"."
96  echo "Contact scripts@mit.edu for assistance."
97  exit 1
98fi
99
[127]100success() {
101  if [ "$initlname" -eq 0 ]; then
102    echo
103    echo "== SUCCESS =="
[458]104    echo "$lname is now signed up for $1."
105    echo "$2"
[127]106    echo
107  fi
108}
Note: See TracBrowser for help on using the repository browser.