source: locker/bin/signup-minimal @ 658

Last change on this file since 658 was 658, checked in by andersk, 14 years ago
Unbreak for sun machines.
  • Property svn:executable set to *
File size: 2.8 KB
RevLine 
[641]1#!/bin/bash
[127]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)."
[658]34        while true; do
35            printf "Locker name: "
36            read lname
37            if attach "$lname" 2>/dev/null; then
38                break
39            fi
40            echo "$lname is not a valid locker name."
[640]41        done
[127]42        lroot="/mit/$lname"
43    else
44        echo
[458]45        echo "ERROR:"
46        echo "You must select either '1' or '2'."
[127]47        exit 1
48    fi
49  else
50    lname=$1
51  fi
52fi
53
[629]54ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/fsla.php/mit/$lname"`
55if [ "$ans" != "0" ]; then
56  echo
57  echo "ERROR:"
58  echo "The scripts servers cannot verify the permissions of the locker <$lname>."
59  echo "Try running \"fs sa /mit/$lname daemon.scripts l\" (with a lowercase"
60  echo "L at the end) and then try again. Contact scripts@mit.edu if you are"
61  echo "unable to solve the problem."
62  exit 1
63fi
64
[576]65principal=`klist -5 | sed -n 's/^Default principal: // p'`
66ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/admof.php/$lname/$principal"`
67if [ "$ans" != "yes" ]; then
68  afsuser=`echo "$principal" | sed 's/@ATHENA.MIT.EDU$//'`
69  echo
70  echo "ERROR:"
71  echo "It appears as though you are not an administrator of the locker <$lname>."
72  echo "Try running \"fs sa /mit/$lname $afsuser all\" and starting over."
73  echo "Contact scripts@mit.edu if you are unable to solve the problem."
74  exit 1
75fi
76
[458]77mkdir "/mit/$lname/.scripts-signup" 2>/dev/null
[127]78
79if [ ! -d "/mit/$lname/.scripts-signup" ]; then
80  echo
[458]81  echo "ERROR:"
82  echo "It appears as though you do not have write access to the locker <$lname>."
83  echo "Contact scripts@mit.edu if you are unable to solve the problem."
[502]84  exit 1
[127]85fi
86
[502]87ans=`$WGET -q -O- "http://scripts.mit.edu/~signup/$lname"`
[458]88rmdir "/mit/$lname/.scripts-signup"
89
[502]90if [ "$ans" != "done" ] && [ "$ans" != "username already taken" ]; then
91  echo "ERROR:"
92  echo "Signup reported the following error: \"$ans\"."
93  echo "Contact scripts@mit.edu for assistance."
94  exit 1
95fi
96
[127]97success() {
98  if [ "$initlname" -eq 0 ]; then
99    echo
100    echo "== SUCCESS =="
[458]101    echo "$lname is now signed up for $1."
102    echo "$2"
[127]103    echo
104  fi
105}
Note: See TracBrowser for help on using the repository browser.