1 | #!/bin/sh |
---|
2 | |
---|
3 | if [ "$initlname" = "" ]; then |
---|
4 | if [ "$lname" = "" ]; then |
---|
5 | initlname=0 |
---|
6 | else |
---|
7 | initlname=1 |
---|
8 | fi |
---|
9 | fi |
---|
10 | |
---|
11 | if [ "$lname" = "" ]; then |
---|
12 | if [ "$1" = "" ]; then |
---|
13 | echo |
---|
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\'. |
---|
18 | printf "Please enter either '1' or '2' (without quotes): " |
---|
19 | read whofor |
---|
20 | if [ "$whofor" -eq 1 ]; then |
---|
21 | lname=$USER |
---|
22 | lroot=$HOME |
---|
23 | elif [ "$whofor" -eq 2 ]; then |
---|
24 | echo |
---|
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. |
---|
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 |
---|
33 | echo ERROR: |
---|
34 | echo You must select either '1' or '2'. |
---|
35 | exit 1 |
---|
36 | fi |
---|
37 | else |
---|
38 | lname=$1 |
---|
39 | fi |
---|
40 | fi |
---|
41 | |
---|
42 | attach $lname 2>/dev/null |
---|
43 | |
---|
44 | if [ "$lname" != "$USER" ]; then |
---|
45 | temp=$lname |
---|
46 | lname=$USER |
---|
47 | . /mit/scripts/bin$scriptsdev/signup-minimal |
---|
48 | lname=$temp |
---|
49 | |
---|
50 | ans=`sshmic -k scripts.mit.edu /usr/local/bin/admof $lname ${USER}@ATHENA.MIT.EDU` |
---|
51 | if [ "$ans" != "yes" ]; then |
---|
52 | echo |
---|
53 | echo ERROR: |
---|
54 | printf "It appears as though you are not an administrator of the locker <$lname>.\n" |
---|
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. |
---|
57 | exit 0 |
---|
58 | fi |
---|
59 | fi |
---|
60 | |
---|
61 | attach $lname 2>/dev/null |
---|
62 | |
---|
63 | if [ ! -d "/mit/$lname" ]; then |
---|
64 | echo |
---|
65 | echo ERROR: |
---|
66 | printf "Cannot find locker <$lname>." |
---|
67 | exit 0 |
---|
68 | fi |
---|
69 | |
---|
70 | mkdir /mit/$lname/.scripts-signup 2>/dev/null |
---|
71 | |
---|
72 | if [ ! -d "/mit/$lname/.scripts-signup" ]; then |
---|
73 | echo |
---|
74 | echo ERROR: |
---|
75 | printf "It appears as though you do not have write access to the locker <$lname>.\n" |
---|
76 | echo Contact scripts@mit.edu if you are unable to solve the problem. |
---|
77 | exit 0 |
---|
78 | fi |
---|
79 | |
---|
80 | athrun gnu wget -q -O/dev/null http://scripts.mit.edu/~signup/signup.php\?username=$lname |
---|
81 | rmdir /mit/$lname/.scripts-signup |
---|
82 | |
---|
83 | success() { |
---|
84 | if [ "$initlname" -eq 0 ]; then |
---|
85 | echo |
---|
86 | echo "== SUCCESS ==" |
---|
87 | echo $lname is now signed up for $1. |
---|
88 | echo $2 |
---|
89 | echo |
---|
90 | fi |
---|
91 | } |
---|