Description:
Update install.sh revert back to use single user rvm instead also fix the secret file generating script
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r267:a92e27ea4e22 - - 1 file changed: 15 inserted, 23 deleted

@@ -1,78 +1,72
1 1 #!/bin/sh
2 2
3 3 #installation script for cafe-grader, for ubuntu 16.04
4 4
5 5 echo "This script will install and configure Cafe grader."
6 6
7 7 RUBY_VERSION=2.3.4
8 8 echo "This will install Ruby $RUBY_VERSION under RVM"
9 9
10 10 echo "Installing required apts"
11 11
12 - sudo apt-get install software-properties-common
13 - sudo apt-add-repository -y ppa:rael-gc/rvm
14 12 sudo apt-get update
15 - sudo apt-get install rvm mysql-server mysql-client \
13 + sudo apt-get install mysql-server mysql-client \
16 14 g++ gcc apache2 libmysqlclient20 build-essential \
17 15 git-core openssl libreadline6 libreadline6-dev \
18 16 zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev \
19 17 sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev \
20 18 ncurses-dev automake libtool bison subversion \
21 19 pkg-config curl nodejs unzip pyflakes ruby default-jdk \
22 20 libmysqld-dev mercurial python-setuptools python-dev python3-numpy
23 21
24 - #--- edited --
25 - #--- we now use rvm from ubuntu package ---
26 - #echo "Installing RVM"
27 - #curl -k -L https://get.rvm.io | bash -s stable
28 - #source ~/.rvm/scripts/rvm
29 -
30 - source /etc/profile.d/rvm.sh
22 + echo "Installing RVM"
23 + curl -k -L https://get.rvm.io | bash -s stable
24 + source ~/.rvm/scripts/rvm
31 25
32 26 echo "Installing Ruby $RUBY_VERSION in RVM"
33 27
34 28 rvm install $RUBY_VERSION
35 29 rvm use $RUBY_VERSION
36 30
37 31 echo "Fetching Cafe Grader from Git repositories"
38 32
39 33 echo "Fetching web interface"
40 34
41 35 mkdir cafe_grader
42 36 cd cafe_grader
43 37 git clone -q git://github.com/cafe-grader-team/cafe-grader-web.git web
44 38
45 39 echo "Configuring rails app"
46 40
47 41 cp web/config/application.rb.SAMPLE web/config/application.rb
48 42 cp web/config/initializers/cafe_grader_config.rb.SAMPLE web/config/initializers/cafe_grader_config.rb
49 43
50 44 #replace UTC in application.rb with the system timezone
51 45 timezone='UTC'
52 46 if [ -f '/etc/timezone' ]; then
53 47 timezone=\"`cat /etc/timezone`\"
54 48 else
55 49 if [ -f '/etc/sysconfig/clock' ]; then
56 50 timezone=`grep -e '^TIMEZONE' /etc/sysconfig/clock | grep -o -e '\".*\"'`
57 51 fi
58 52 fi
59 53 replace="s!'UTC'!$timezone!g"
60 54 sed -i $replace web/config/application.rb
61 55
62 56 echo "At this point we will need MySQL user and database."
63 57 echo "Have you created MySQL user and database for Cafe grader? (Y/N) "
64 58 read ch
65 59
66 60 if [ "$ch" = "n" -o "$ch" = "N" ]
67 61 then
68 62 echo "Please open another terminal and create the user and database for Cafe grader."
69 63 echo "Don't forget to grant access to that database for the user."
70 64 echo "Please have username, password, and database name ready before continue."
71 65 echo
72 66 echo "The following are instructions:"
73 67 echo "1. Run mysql:"
74 68 echo
75 69 echo " mysql -u root -p"
76 70 echo
77 71 echo " if you have just installed mysql, the root password is the one that you have just entered"
78 72 echo "2. Create a new database, a new user, and grant access to grader database:"
@@ -82,121 +76,119
82 76 echo " grant all on \`DATABASENAME\`.* to 'USERNAME'@'localhost';"
83 77 echo
84 78 echo " Replace USERNAME, PASSWORD, and DATABASENAME accordingly."
85 79 echo
86 80 echo "Hit enter when ready..."
87 81 read dummy
88 82 fi
89 83
90 84 CAFE_PATH=`pwd`
91 85
92 86 cd web
93 87
94 88 echo "Please provide grader database:"
95 89 read database
96 90
97 91 echo "Please provide grader username:"
98 92 read username
99 93
100 94 echo "Please provide $username password:"
101 95 read password
102 96
103 97 echo "development:" > config/database.yml
104 98 echo " adapter: mysql2" >> config/database.yml
105 99 echo " encoding: utf8" >> config/database.yml
106 100 echo " reconnect: false" >> config/database.yml
107 101 echo " database: $database" >> config/database.yml
108 102 echo " pool: 5" >> config/database.yml
109 103 echo " username: $username" >> config/database.yml
110 104 echo " password: $password" >> config/database.yml
111 105 echo " host: localhost" >> config/database.yml
112 106 echo " socket: /var/run/mysqld/mysqld.sock" >> config/database.yml
113 107 echo "" >> config/database.yml
114 108 echo "production:" >> config/database.yml
115 109 echo " adapter: mysql2" >> config/database.yml
116 110 echo " encoding: utf8" >> config/database.yml
117 111 echo " reconnect: false" >> config/database.yml
118 112 echo " database: $database" >> config/database.yml
119 113 echo " pool: 5" >> config/database.yml
120 114 echo " username: $username" >> config/database.yml
121 115 echo " password: $password" >> config/database.yml
122 116 echo " host: localhost" >> config/database.yml
123 117 echo " socket: /var/run/mysqld/mysqld.sock" >> config/database.yml
124 118
125 119 echo "Object.instance_eval{remove_const :GRADER_ROOT_DIR}" >> config/initializers/cafe_grader_config.rb
126 120 echo "Object.instance_eval{remove_const :GRADING_RESULT_DIR}" >> config/initializers/cafe_grader_config.rb
127 121 echo "GRADER_ROOT_DIR = '$CAFE_PATH/judge'" >> config/initializers/cafe_grader_config.rb
128 122 echo "GRADING_RESULT_DIR = '$CAFE_PATH/judge/result'" >> config/initializers/cafe_grader_config.rb
129 123
130 - # setup secret file
131 - SECRET_A=`rake secret`
132 - SECRET_B=`rake secret`
133 - SECRET_C=`rake secret`
134 - echo "development:" > config/secrets.yml
135 - echo " secret_key_base: '$SECRET_A'" >> config/secrets.yml
136 - echo "test:" >> config/secrets.yml
137 - echo " secret_key_base: '$SECRET_B'" >> config/secrets.yml
138 - echo "production:" >> config/secrets.yml
139 - echo " secret_key_base: '$SECRET_C'" >> config/secrets.yml
140 -
141 -
142 -
143 124 echo "Installing required gems"
144 125 gem install bundler
145 126 bundle install
146 127
147 128 echo "Running rake tasks to initialize database"
148 129
149 130 rake db:migrate
150 131 rake db:seed
151 132
152 133 echo "Running rake tasks to precompile the assets"
153 134
154 135 rake assets:precompile
155 136
137 + echo "setup the secret file"
138 + SECRET_A=`rake secret`
139 + SECRET_B=`rake secret`
140 + SECRET_C=`rake secret`
141 + echo "development:" > config/secrets.yml
142 + echo " secret_key_base: '$SECRET_A'" >> config/secrets.yml
143 + echo "test:" >> config/secrets.yml
144 + echo " secret_key_base: '$SECRET_B'" >> config/secrets.yml
145 + echo "production:" >> config/secrets.yml
146 + echo " secret_key_base: '$SECRET_C'" >> config/secrets.yml
147 +
156 148 echo "Intalling web interface complete..."
157 149 echo
158 150 echo "Fetching grader"
159 151
160 152 cd ..
161 153
162 154 mkdir judge
163 155 cd judge
164 156 git clone -q git://github.com/cafe-grader-team/cafe-grader-judge-scripts.git scripts
165 157 mkdir raw
166 158 mkdir ev-exam
167 159 mkdir ev
168 160 mkdir result
169 161 mkdir log
170 162
171 163 echo "Configuring grader"
172 164
173 165 cp scripts/config/env_exam.rb.SAMPLE scripts/config/env_exam.rb
174 166 cp scripts/config/env_grading.rb.SAMPLE scripts/config/env_grading.rb
175 167
176 168 # create new environment.rb file
177 169 echo "RAILS_ROOT = '$CAFE_PATH/web'" > scripts/config/environment.rb
178 170 echo "GRADER_ROOT = '$CAFE_PATH/judge/scripts'" >> scripts/config/environment.rb
179 171 echo "require File.join(File.dirname(__FILE__),'../lib/boot')" >> scripts/config/environment.rb
180 172 echo "require File.dirname(__FILE__) + \"/env_#{GRADER_ENV}.rb\"" >> scripts/config/environment.rb
181 173
182 174 # compiling box
183 175 MACHINE_TYPE=`uname -m`
184 176 if [ ${MACHINE_TYPE} == 'x86_64' ]; then
185 177 gcc -std=c99 -o scripts/std-script/box scripts/std-script/box64-new.c
186 178 else
187 179 g++ -o scripts/std-script/box scripts/std-script/box.cc
188 180 fi
189 181
190 182
191 183 cd ..
192 184
193 185 echo "Now you are ready to run cafe grader...."
194 186 echo
195 187 echo "Try:"
196 188 echo
197 189 echo " cd web"
198 190 echo " rails s"
199 191 echo
200 192 echo "and access web at http://localhost:3000/"
201 193 echo "The root username is 'root', its password is 'ioionrails'."
202 194
You need to be logged in to leave comments. Login now