Description:
Merge pull request #5 from nattee/master update install script
Commit status:
[Not Reviewed]
References:
merge default
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r199:eb52412d0a7d - - 1 file changed: 16 inserted, 0 deleted

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