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