source: locker/bin/signup-sql @ 382

Last change on this file since 382 was 382, checked in by presbrey, 17 years ago
new SQL signup and server
  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#!/bin/sh
2
3checkfailed() {
4  if [ -f "$lroot/web_scripts/$addrend/.failed" ]; then
5    rm -f $lroot/web_scripts/$addrend/.failed
6    exit 1
7  fi
8}
9
10sshrun() {
11  athrun scripts sshmic ${lname}@scripts.mit.edu /mit/scripts/$1 2>/dev/null
12}
13
14vsshrun() {
15  athrun scripts sshmic ${lname}@scripts.mit.edu /mit/scripts/$1
16}
17
18checksqlpass() {
19    errors=`sshrun 'sql/bin$scriptsdev/test-password'`
20    if [ "$errors" != "" ]; then
21        if [ "$1" -eq 1 ]; then
22          rm -f $lroot/.sql/my.cnf
23        fi
24        echo
25        echo ERROR:
26        printf "$2"
27        printf "$3"
28        exit
29    fi
30}
31
32echo
33echo == Welcome to the sql.mit.edu signup process ==
34echo
35
36echo "For documentation, including a link to the Athena rules of use,"
37echo "see <http://sql.mit.edu>."
38echo
39echo Please report problems with this signup process to sql@mit.edu.
40echo
41echo Are you performing this signup for:
42echo 1. Your personal Athena account
43echo 2. A locker that you control \(a club, a course, etc\)
44echo If you do not understand this question, you should answer \'1\'.
45printf "Please enter either '1' or '2' (without quotes): "
46read whofor
47if [ "$whofor" -eq 1 ]; then
48    lname=$USER
49    lroot=$HOME 
50elif [ "$whofor" -eq 2 ]; then
51    echo
52    echo OK.  A MySQL account will be created for a locker of your choice that
53    echo you control.  Please enter the name of the selected locker below.
54    echo "(For the locker /mit/sipb, you would enter sipb)."
55    printf "Locker name: "
56    read lname
57    lroot="/mit/$lname" 
58else
59    echo
60    echo ERROR:
61    echo You must select either '1' or '2'.
62    exit 1
63fi
64
65# Users need to sign up for scripts.mit.edu so that they can
66# authenticate themselves to sql.mit.edu
67attach scripts 2>/dev/null
68. /mit/scripts/bin$scriptsdev/signup-web
69
70if [ "$requires_sql" = "" ]; then
71  requires_sql=1
72fi
73
74if [ ! -f "$lroot/.my.cnf" ]; then
75  mkdir $lroot/.sql 2>/dev/null
76  fs sa $lroot/.sql system:anyuser none
77  fs sa $lroot/.sql system:authuser none
78  fs sa $lroot/.sql daemon.scripts write
79  fs sa $lroot/.sql daemon.sql write
80  ln -nfs $lroot/.sql/my.cnf $lroot/.my.cnf 2>/dev/null
81fi
82
83if [ "$requires_sql" -eq 1 ]; then
84  sqlinfo=`sshrun "sql/bin$scriptsdev/get-password"`
85  if [ "$sqlinfo" = "" ]; then
86      echo
87      echo You already have a MySQL account but you do not have a .my.cnf file.
88      echo If you do not remember your MySQL account password, you can change it
89      echo at http://sql.mit.edu using MIT certificates.
90      printf "Please type your MySQL password and press [enter]: "
91      stty -echo
92      read sqlpass
93      stty echo
94      echo
95      sqlhost="sql.mit.edu"
96      sqluser=$lname
97      . /mit/scripts/sql/bin$scriptsdev/save-password
98      checksqlpass 1 'The MySQL password that you typed appears to be incorrect.\n' ''
99      echo
100      echo OK.  Continuing with the install...
101  else
102      checksqlpass 0 'The MySQL login information in your .my.cnf file\n' 'appears to be incorrect.\n'
103  fi
104fi
105
106echo
107echo == Setup complete! ==
108echo Your MySQL login information has been written to the file
109echo "</mit/$lname/.sql/my.cnf>."
110echo You must use the sql.mit.edu web interface to add or drop databases.
111echo If you have trouble with your MySQL account, feel free to contact
112echo the sql.mit.edu team by e-mailing sql@mit.edu
113exit 0
Note: See TracBrowser for help on using the repository browser.