1 | #!/bin/sh |
---|
2 | |
---|
3 | checkfailed() { |
---|
4 | if [ -f "$lroot/web_scripts/$addrend/.failed" ]; then |
---|
5 | rm -f $lroot/web_scripts/$addrend/.failed |
---|
6 | exit 1 |
---|
7 | fi |
---|
8 | } |
---|
9 | |
---|
10 | sshrun() { |
---|
11 | athrun scripts scripts-ssh "$lname" "/mit/scripts/$@" 2>/dev/null |
---|
12 | } |
---|
13 | |
---|
14 | vsshrun() { |
---|
15 | athrun scripts scripts-ssh "$lname" "/mit/scripts/$@" |
---|
16 | } |
---|
17 | |
---|
18 | checksqlpass() { |
---|
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 | |
---|
32 | echo |
---|
33 | echo == Welcome to the sql.mit.edu signup process == |
---|
34 | echo |
---|
35 | |
---|
36 | echo "For documentation, including a link to the Athena rules of use," |
---|
37 | echo "see <http://sql.mit.edu>." |
---|
38 | echo |
---|
39 | echo Please report problems with this signup process to sql@mit.edu. |
---|
40 | echo |
---|
41 | echo Are you performing this signup for: |
---|
42 | echo 1. Your personal Athena account |
---|
43 | echo 2. A locker that you control \(a club, a course, etc\) |
---|
44 | echo "If you do not understand this question, you should answer '1'". |
---|
45 | printf "Please enter either '1' or '2' (without quotes): " |
---|
46 | read whofor |
---|
47 | if [ "$whofor" -eq 1 ]; then |
---|
48 | lname=$USER |
---|
49 | lroot=$HOME |
---|
50 | elif [ "$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 | while true; do |
---|
56 | printf "Locker name: " |
---|
57 | read lname |
---|
58 | if attach "$lname"; then |
---|
59 | break |
---|
60 | fi |
---|
61 | echo "$lname is not a valid locker name." |
---|
62 | done |
---|
63 | lroot="/mit/$lname" |
---|
64 | else |
---|
65 | echo |
---|
66 | echo ERROR: |
---|
67 | echo You must select either '1' or '2'. |
---|
68 | exit 1 |
---|
69 | fi |
---|
70 | |
---|
71 | # Users need to sign up for scripts.mit.edu so that they can |
---|
72 | # authenticate themselves to sql.mit.edu |
---|
73 | attach scripts |
---|
74 | . /mit/scripts/bin$scriptsdev/signup-web |
---|
75 | |
---|
76 | if [ "$requires_sql" = "" ]; then |
---|
77 | requires_sql=1 |
---|
78 | fi |
---|
79 | |
---|
80 | if [ ! -f "$lroot/.my.cnf" ]; then |
---|
81 | mkdir -p $lroot/.sql |
---|
82 | fs sa $lroot/.sql system:anyuser none |
---|
83 | fs sa $lroot/.sql system:authuser none |
---|
84 | fs sa $lroot/.sql daemon.scripts write |
---|
85 | fs sa $lroot/.sql daemon.sql write |
---|
86 | ln -nfs $lroot/.sql/my.cnf $lroot/.my.cnf |
---|
87 | fi |
---|
88 | |
---|
89 | if [ "$requires_sql" -eq 1 ]; then |
---|
90 | sqlinfo=`sshrun "sql/bin$scriptsdev/get-password"` |
---|
91 | if [ "$sqlinfo" = "" ]; then |
---|
92 | echo |
---|
93 | echo You already have a MySQL account but you do not have a .my.cnf file. |
---|
94 | echo If you do not remember your MySQL account password, you can change it |
---|
95 | echo at http://sql.mit.edu using MIT certificates. |
---|
96 | printf "Please type your MySQL password and press [enter]: " |
---|
97 | stty -echo |
---|
98 | read sqlpass |
---|
99 | stty echo |
---|
100 | echo |
---|
101 | sqlhost="sql.mit.edu" |
---|
102 | sqluser=$lname |
---|
103 | . /mit/scripts/sql/bin$scriptsdev/save-password |
---|
104 | checksqlpass 1 'The MySQL password that you typed appears to be incorrect.\n' '' |
---|
105 | echo |
---|
106 | echo OK. Continuing with the install... |
---|
107 | else |
---|
108 | checksqlpass 0 'The MySQL login information in your .my.cnf file\n' 'appears to be incorrect.\n' |
---|
109 | fi |
---|
110 | fi |
---|
111 | |
---|
112 | echo |
---|
113 | echo == Setup complete! == |
---|
114 | echo Your MySQL login information has been written to the file |
---|
115 | echo "</mit/$lname/.sql/my.cnf>." |
---|
116 | echo You must use the sql.mit.edu web interface to add or drop databases. |
---|
117 | echo If you have trouble with your MySQL account, feel free to contact |
---|
118 | echo the sql.mit.edu team by e-mailing sql@mit.edu |
---|
119 | exit 0 |
---|