rhoconnect 3.0.0.beta1 → 3.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/CHANGELOG +16 -2
  2. data/Gemfile +14 -5
  3. data/Gemfile.lock +13 -23
  4. data/Rakefile +86 -0
  5. data/bench/bench_runner.rb +5 -4
  6. data/bench/benchapp/Gemfile +17 -8
  7. data/bench/blobapp/Gemfile +13 -14
  8. data/doc/adapters-crm.txt +226 -0
  9. data/doc/adapters-intro.txt +18 -0
  10. data/doc/client.txt +29 -2
  11. data/doc/heroku-addon.txt +54 -0
  12. data/doc/install.txt +1 -2
  13. data/doc/migration.txt +18 -6
  14. data/doc/net-plugin.txt +276 -0
  15. data/doc/plugin-intro.txt +6 -0
  16. data/doc/push.txt +1 -1
  17. data/doc/rails-plugin.txt +116 -0
  18. data/doc/rest-api.txt +2 -2
  19. data/doc/settings.txt +59 -0
  20. data/doc/tutorial.txt +8 -5
  21. data/generators/rhoconnect.rb +30 -0
  22. data/generators/templates/application/Gemfile +16 -7
  23. data/generators/templates/application/gitignore +4 -0
  24. data/install.sh +74 -106
  25. data/installer/deb-scripts/LICENSE +75 -0
  26. data/installer/deb-scripts/install.sh +300 -0
  27. data/installer/deb-scripts/scripts/rho_connect_install_constants.rb +32 -0
  28. data/installer/deb-scripts/scripts/rho_connect_install_installers.rb +103 -0
  29. data/installer/deb-scripts/scripts/rho_connect_install_utilities.rb +110 -0
  30. data/installer/deb-scripts/scripts/rhoinstaller.rb +55 -0
  31. data/installer/deb-scripts/utils/README +67 -0
  32. data/installer/deb-scripts/utils/create_texts.rb +76 -0
  33. data/installer/deb-scripts/utils/redis_init_script +124 -0
  34. data/installer/deb-scripts/utils/redis_log_rotate +8 -0
  35. data/installer/unix-like/install.sh +361 -0
  36. data/installer/unix-like/post-install.sh +8 -0
  37. data/installer/unix-like/pre-install.sh +8 -0
  38. data/installer/unix-like/rho_connect_install_constants.rb +9 -14
  39. data/installer/unix-like/rho_connect_install_debian.rb +7 -5
  40. data/installer/unix-like/rho_connect_install_dnd.rb +6 -6
  41. data/installer/unix-like/rho_connect_install_get_params.rb +1 -1
  42. data/installer/unix-like/rho_connect_install_installers.rb +39 -38
  43. data/installer/unix-like/rho_connect_install_utilities.rb +9 -10
  44. data/installer/unix-like/rho_connect_install_yum.rb +6 -5
  45. data/installer/unix-like/rhoinstaller.rb +8 -3
  46. data/installer/utils/create_texts.rb +313 -85
  47. data/installer/windows/rhosync.nsi +5 -5
  48. data/lib/rhoconnect/api/application/clientcreate.rb +1 -1
  49. data/lib/rhoconnect/api/application/clientregister.rb +1 -1
  50. data/lib/rhoconnect/api/application/clientreset.rb +1 -1
  51. data/lib/rhoconnect/client.rb +0 -1
  52. data/lib/rhoconnect/client_sync.rb +1 -0
  53. data/lib/rhoconnect/console/app/routes/home.rb +1 -1
  54. data/lib/rhoconnect/console/app/routes/user.rb +8 -3
  55. data/lib/rhoconnect/console/app/views/adapter.erb +2 -2
  56. data/lib/rhoconnect/console/app/views/ping.erb +14 -2
  57. data/lib/rhoconnect/console/app/views/users.erb +8 -1
  58. data/lib/rhoconnect/jobs/ping_job.rb +11 -3
  59. data/lib/rhoconnect/model.rb +2 -2
  60. data/lib/rhoconnect/read_state.rb +2 -0
  61. data/lib/rhoconnect/server.rb +4 -3
  62. data/lib/rhoconnect/source.rb +33 -6
  63. data/lib/rhoconnect/source_adapter.rb +5 -9
  64. data/lib/rhoconnect/source_sync.rb +11 -5
  65. data/lib/rhoconnect/store.rb +7 -4
  66. data/lib/rhoconnect/tasks.rb +3 -3
  67. data/lib/rhoconnect/version.rb +1 -1
  68. data/lib/rhoconnect.rb +22 -8
  69. data/rhoconnect.gemspec +4 -22
  70. data/spec/api/application/rhoconnect_api_spec.rb +54 -8
  71. data/spec/api/source/get_source_params_spec.rb +2 -1
  72. data/spec/api/source/list_sources_spec.rb +3 -3
  73. data/spec/app_spec.rb +8 -1
  74. data/spec/apps/rhotestapp/settings/settings.yml +10 -5
  75. data/spec/apps/rhotestapp/sources/other_adapter.rb +7 -0
  76. data/spec/client_sync_spec.rb +5 -8
  77. data/spec/dynamic_adapter_spec.rb +8 -8
  78. data/spec/generator/generator_spec.rb +4 -2
  79. data/spec/jobs/ping_job_spec.rb +53 -0
  80. data/spec/model_spec.rb +2 -2
  81. data/spec/rhosync_spec.rb +1 -1
  82. data/spec/server/server_spec.rb +3 -14
  83. data/spec/source_sync_spec.rb +84 -2
  84. data/spec/support/shared_examples.rb +2 -2
  85. data/tasks/redis.rake +2 -2
  86. metadata +30 -41
  87. data/spec/api/rhosync_api_spec.rb.orig +0 -606
@@ -0,0 +1,300 @@
1
+ #!/bin/bash
2
+
3
+ # CONSTANTS
4
+
5
+ PASSENGER_VERSION="passenger-3.0.9"
6
+
7
+ RUBY="ruby-enterprise-1.8.7-2011.03"
8
+ REDIS="redis-2.2.12"
9
+ SQLITE3="sqlite-autoconf-3070701"
10
+ SOFTWARE= ($REDIS $SQLITE3)
11
+
12
+ RUBY_TAR="${RUBY}.tar.gz"
13
+ REDIS_TAR="${REDIS}.tar.gz"
14
+ SQLITE3_TAR="${SQLITE3}.tar.gz"
15
+ TARS=($REDIS_TAR $SQLITE3_TAR)
16
+
17
+ RUBY_URL="http://rubyenterpriseedition.googlecode.com/files/${RUBY_TAR}"
18
+ REDIS_URL="http://redis.googlecode.com/files/${REDIS_TAR}"
19
+ SQLITE3_URL="http://www.sqlite.org/${SQLITE3_TAR}"
20
+ URLS=($REDIS_URL $SQLITE3_URL)
21
+
22
+ GEMS=("bundler" "passenger")
23
+
24
+ PKG_MGR="apt-get"
25
+
26
+ WEB_SERVER="nginx"
27
+
28
+ WEB_SERVER_URL="http://localhost/"
29
+
30
+ DEFAULT_INSTALL_DIR="/opt/rhoconnect"
31
+
32
+ # INITIALIZATIONS
33
+
34
+ timeInitial=`date +%H%M%S`
35
+ installTime=$timeInitial
36
+
37
+ # FUNCTIONS
38
+
39
+ echoLog(){
40
+ echo -e $1 | tee -a $log
41
+ } #end echoLog
42
+
43
+ # cmd
44
+ # This method issues the given system command and calls log_print for output
45
+ cmd(){
46
+ cmd=$1
47
+ echoLog cmd
48
+ echoLog `${cmd}`
49
+ } #end cmd
50
+
51
+ checkDeps(){
52
+ deps=("zlib1g-dev" "libreadline5-dev" "build-essential" "libssl-dev"
53
+ "libcurl4-openssl-dev" "libapr1-dev" "libaprutil1-dev"
54
+ "gcc" "make" "wget")
55
+ i="0"
56
+ missing=""
57
+
58
+ while [[ ${deps[$i]} != "" ]]; do
59
+ pkg=${deps[$i]}
60
+ pkgChk=`dpkg -l | grep -w ${pkg}`
61
+ if [[ $pkgChk == "" ]]; then
62
+ missing=$missing$pkg"\n"
63
+ fi
64
+ i=$[i+1]
65
+ done
66
+
67
+ if [[ $missing != "" ]]; then
68
+ echoLog "Some dependencies must be installed before the setup can continue..."
69
+ echoLog $missing
70
+ exit
71
+ fi
72
+
73
+ } #end checkDeps
74
+
75
+ setPrefixDependantPaths (){
76
+ # if rubyBinDir not specified
77
+ if [$rubyBinDir == ""]; then
78
+ rubyBinDir="${prefix}/ruby/bin"
79
+ fi
80
+
81
+ # If logs directory does not exist, create it
82
+ if ! [[ -d "${prefix}/logs/" ]]; then
83
+ mkdir "${prefix}/logs/"
84
+ fi
85
+
86
+ # Make path to log file absolute and create directory if not already existent
87
+ log="${prefix}/logs/${log}"
88
+ touch $log
89
+
90
+ # Add the log file path to the info file
91
+ echo $log >> info.dat
92
+ cat info.dat
93
+
94
+ # Move info.dat into installation directory if not already there
95
+ if ! [ -e "${prefix}/info.dat" ]; then
96
+ mv info.dat "${prefix}/info.dat"
97
+ fi
98
+ } #end setPrefixDependantPaths
99
+
100
+ setDefaults (){
101
+ # if $prefix not specified set to /opt/rhoconnect
102
+ if [$prefix == ""]; then
103
+ prefix=$DEFAULT_INSTALL_DIR
104
+ fi
105
+
106
+ # if $webServer not specified set to apache2
107
+ if [$webServer == ""]; then
108
+ webServer=$WEB_SERVER
109
+ fi
110
+ } #end setDefaults
111
+
112
+ logAndPrint (){
113
+ $1 > tempout 2>&1
114
+ exitStatus=$?
115
+ cat tempout | tee -a $log
116
+ } #end logAndPrint
117
+
118
+ # installRuby
119
+ # Installs ruby enterprise edition
120
+ installRuby (){
121
+ if [[ ! -d "${prefix}${RUBY}" ]]; then
122
+ echoLog "Loading ruby tarball ..."
123
+ cmd "wget -P ${prefix} ${RUBY_URL}"
124
+ cmd "tar -xzf ${prefix}/${RUBY_TAR} -C ${prefix}"
125
+ fi
126
+
127
+ echoLog "Installing ruby. This may take some time..."
128
+
129
+ logAndPrint "${prefix}/${RUBY}/installer --dont-install-useful-gems --no-dev-docs --auto ${prefix}"
130
+
131
+ if [[ $exitStatus != 0 ]]; then
132
+ echoLog "Some dependencies not installed..."
133
+ echoLog "Please install them and then re-run the installation script."
134
+ exit
135
+ fi
136
+
137
+ PATH=${prefix}:$PATH
138
+
139
+ rm tempout
140
+ } #end installRuby
141
+
142
+ # download
143
+ # Downloads file stored at given URL to the given prefix unlessit already
144
+ # exists
145
+ download(){
146
+ url=$1
147
+ prefix=$2
148
+ downloads="./downloads"
149
+ found=""
150
+
151
+ if [ -e $downloads ]; then
152
+ while read line; do
153
+ if ! [ "${line}" == "${url}" ]; then
154
+ found="found"
155
+ fi
156
+ done < $downloads
157
+ fi
158
+
159
+ if [ "${found}" == "" ]; then
160
+ cmd "wget -P ${prefix} ${url}"
161
+ echo ${url} >> $downloads
162
+ fi
163
+
164
+ rm $downloads
165
+ } #end download
166
+
167
+ # decompress
168
+ # Decompresses downloaded files unless already decompressed directory
169
+ # exists
170
+ decompress(){
171
+ tar=$1
172
+ prefix=$2
173
+
174
+ cmd "tar -xzvf ${prefix}/${tar} -C ${prefix}"
175
+ } #end decompress
176
+
177
+ # downloadAndDecompress
178
+ # 1) Iterates through the the list of URLs and downloads each item
179
+ # 2) Iterates through the list of TARs and unpacks each one
180
+ downloadAndDecompress(){
181
+ prefix=$1
182
+ for (( i=0; i < ${#URLS[@]}; i++ )); do
183
+ download ${URLS[$i]} ${prefix}
184
+ done #for
185
+
186
+ for (( i=0; i < ${#TARS[@]}; i++ )); do
187
+ decompress ${#TARS[$i]} ${prefix}
188
+ done #for
189
+ } #end downloadAndDecompress
190
+
191
+ rhoinstaller(){
192
+
193
+ } #end rhoinstaller
194
+
195
+ # SCRIPT
196
+ checkDeps
197
+
198
+ # define log file name
199
+ datefile=`date +%Y%m%d%H%M%S`
200
+ log=rhoconnect_$(date +$datefile).log
201
+
202
+ # define option variables
203
+ opts=""
204
+ prefix=""
205
+ getVal=""
206
+ webServer=""
207
+ rubyBinDir=""
208
+
209
+ # Set default Values
210
+ setDefaults
211
+
212
+ # Set ruby insatallation variables
213
+ setRubyVars
214
+
215
+ # Once the prefix path is cleaned up...
216
+ setPrefixDependantPaths
217
+
218
+ # Install ruby if not already installed
219
+ if ! [ -e "${prefix}/bin/ruby" ]; then
220
+ installRuby
221
+ else
222
+ echoLog "Ruby already installed" | tee -a $log
223
+ fi
224
+
225
+ #!/opt/rhoconnect/bin/ruby
226
+
227
+ #require 'rho_connect_install_constants'
228
+ #require 'rho_connect_install_installers'
229
+
230
+ include Installers
231
+
232
+ module Utilities
233
+ extend self
234
+
235
+ # cleanup
236
+ # This method moves all compressed files from the installation directory
237
+ # that were downloaded by this installation process
238
+ def cleanup(options)
239
+ prefix = options[:prefix]
240
+
241
+ print_header "Cleaning up"
242
+
243
+ Dir.mkdir("#{prefix}/downloads") unless File.directory?("#{prefix}/downloads")
244
+ Constants::URLS.each do |url|
245
+ file = get_version url
246
+ if File.exists?("#{prefix}/#{file}")
247
+ cmd "rm -rf #{prefix}/downloads/#{file}"
248
+ cmd "mv #{prefix}/#{file}* #{prefix}/downloads"
249
+ end #if
250
+ end # do
251
+ end #cleanup
252
+ end #utilities
253
+
254
+ # set necessary variables
255
+ :dist => "debian",
256
+ :pkg_mgr => 'apt-get -y',
257
+ :pkg_chkr => 'dpkg -l',
258
+ :start_dir => `pwd`.strip,
259
+ :web_server => Constants::WEB_SERVER}
260
+
261
+ log = Logger.new(IO.readlines("#{@options[:prefix]}/info.dat").last.strip)
262
+ log.datetime_format = "%Y-%m-%d %H:%M:%S" # simplify time output
263
+
264
+ # execute_installation
265
+ # This method orchestrates the actual installation process
266
+ def execute_installation
267
+ install_sqlite @options
268
+
269
+ # Start installing
270
+ install_all_gems @options
271
+ configure_passenger @options
272
+
273
+ # Install Redis
274
+ install_redis @options
275
+
276
+ # Install rhoconnect
277
+ install_rhoconnect @options
278
+
279
+ # Remove downloaded tarballs and extracted directories
280
+ cleanup @options
281
+ end #execute_installation
282
+
283
+ # Start installation process
284
+ download_and_decompress @options[:prefix]
285
+
286
+ execute_installation
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+ # Cleanup
298
+ rm "${prefix}/info.dat"
299
+
300
+ ${prefix}/bin/ruby ./utils/create_texts.rb
@@ -0,0 +1,32 @@
1
+ #!/opt/rhoconnect/bin/ruby
2
+
3
+ module Constants
4
+
5
+ PASSENGER_VERSION = "passenger-3.0.9"
6
+
7
+ #RUBYGEMS = "rubygems-1.8.5"
8
+ REDIS = "redis-2.2.12"
9
+ SQLITE3 = "sqlite-autoconf-3070701"
10
+
11
+ SOFTWARE = [REDIS,
12
+ SQLITE3]
13
+
14
+ #RUBYGEMS_URL = "http://rubyforge.org/frs/download.php/74954/" +
15
+ # "#{ RUBYGEMS }.tgz"
16
+ REDIS_URL = "http://redis.googlecode.com/files/#{ REDIS }.tar.gz"
17
+ SQLITE3_URL = "http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz"
18
+
19
+
20
+ URLS = [REDIS_URL,
21
+ SQLITE3_URL]
22
+
23
+ GEMS = ["bundler", "passenger"]
24
+
25
+ SUPPORTED_PKG_MGRS = ["apt-get", "yum"]
26
+
27
+ WEB_SERVER = "nginx"
28
+
29
+ WEB_SERVER_URL = "http://localhost/"
30
+
31
+ DEFAULT_INSTALL_DIR = "/opt/rhoconnect"
32
+ end #Constants
@@ -0,0 +1,103 @@
1
+ #!/opt/rhoconnect/bin/ruby
2
+
3
+ require 'rho_connect_install_constants'
4
+ require 'readline'
5
+
6
+ module Installers
7
+ extend self
8
+ # configure_passenger
9
+ # This method installs items that were retrieved via wget as well as
10
+ # passenger
11
+ def configure_passenger(options)
12
+ @options = options
13
+ installs = 0
14
+ print_header "Configuring Passenger"
15
+ print_header "Configuring Nginx to work with Passenger"
16
+ cmd "#{@options[:prefix]}/bin/passenger-install-#{@options[:web_server]}-module " +
17
+ "--auto --auto-download --prefix=/opt/rhoconnect/bin"
18
+ if $? != 0
19
+ log_print "Passenger not configured."
20
+ exit
21
+ end #if
22
+ end #configure_passenger
23
+
24
+ # install_all_gems
25
+ # This method installs all gems specified in the GEMS list defined in the
26
+ # Constants file
27
+ def install_all_gems(options)
28
+ @options = options
29
+ @gem_path = "#{@options[:prefix]}/bin/gem"
30
+ Constants::GEMS.each do |gem|
31
+ install_gem gem
32
+ end #do
33
+ end #install_all_gems
34
+
35
+ # install_gem
36
+ # This method installs the given gem
37
+ def install_gem(gem)
38
+ cmd "#{@gem_path} install #{ gem } --no-ri --no-rdoc"
39
+ end #install_gem
40
+
41
+ # install_rubygems
42
+ # This method installs rubygems which was downloaded and untarred earlier
43
+ def install_rubygems
44
+ print_header "Installing Rubygems"
45
+ Dir.chdir("#{@options[:prefix]}/#{Constants::RUBYGEMS}")
46
+ cmd "#{@options[:prefix]}/bin/ruby setup.rb --prefix=#{@options[:prefix]}/#{Constants::RUBYGEMS}"
47
+ @gem_path = "#{@options[:prefix]}/bin/gem"
48
+ cmd "sed -n '1 c\#!/opt/rhoconnect/bin/ruby' #{@options[:prefix]}/bin/gem"
49
+ end #install_rubygems
50
+
51
+ # install_redis
52
+ # This method installs redis
53
+ def install_redis(options)
54
+ @options = options
55
+ puts "\nWould you like to install Redis (yes / no)?"
56
+ answer = STDIN.readline.strip.downcase
57
+ while answer != "yes" &&
58
+ answer != "no"
59
+ puts "Please answer yes or no."
60
+ end
61
+
62
+ if answer == "yes"
63
+ Dir.chdir("#{@options[:prefix]}/#{Constants::REDIS}/src")
64
+ cmd "make; make PREFIX=#{@options[:prefix]} install"
65
+ cmd "mkdir #{@options[:prefix]}/etc" unless File.exist? "#{@options[:prefix]}/etc"
66
+
67
+ #cmd "cp ../redis.conf #{@options[:prefix]}etc"
68
+ redis_conf_file = File.new("#{@options[:prefix]}/etc/redis.conf", 'w')
69
+ File.foreach("../redis.conf") do |line|
70
+ # daemonize no --> daemonize yes
71
+ # logfile stdout --> logfile /var/log/redis.log
72
+ if line =~ /^daemonize/
73
+ redis_conf_file << "daemonize yes" << "\n"
74
+ elsif line =~ /^logfile/
75
+ redis_conf_file << "logfile /var/log/redis.log" << "\n"
76
+ else
77
+ redis_conf_file << line
78
+ end
79
+ end
80
+ redis_conf_file.close
81
+ end #if
82
+ end #install_redis
83
+
84
+ # install_sqlite
85
+ # This method installs sqlite
86
+ def install_sqlite(options)
87
+ @options = options
88
+ Dir.chdir("#{@options[:prefix]}/#{Constants::SQLITE3}")
89
+ cmd "./configure --prefix=#{@options[:prefix]}"
90
+ cmd "make; make install"
91
+ end #install_sqlite
92
+
93
+ # install_rhoconnect
94
+ # This method installs rhoconnect
95
+ def install_rhoconnect(options)
96
+ @options = options
97
+ print_header "Installing Rhoconnect"
98
+
99
+ cmd "#{@gem_path} install rhoconnect-*.gem --no-ri --no-rdoc"
100
+ cmd "rm -f rhoconnect-*.gem"
101
+
102
+ end #install_rhoconnect
103
+ end #Installers
@@ -0,0 +1,110 @@
1
+ #!/opt/rhoconnect/bin/ruby
2
+
3
+ require 'rho_connect_install_constants'
4
+ require 'rho_connect_install_installers'
5
+
6
+ include Installers
7
+
8
+ module Utilities
9
+ extend self
10
+
11
+ # log_print
12
+ # This method displays, in minutes, how long the installation process took
13
+ def log_print(string)
14
+ puts string
15
+ @log.info {string} unless @log == nil
16
+ end #log_print
17
+
18
+ # cmd
19
+ # This method issues the given system command and calls log_print for output
20
+ def cmd(cmd)
21
+ log_print cmd
22
+ log_print `#{ cmd }`
23
+ end #cmd
24
+
25
+ #set_log_file
26
+ def set_log_file(log)
27
+ @log = log
28
+ end #set_log_file
29
+
30
+ # print_header
31
+ # This method displays a header surrounded by '=' characters consisting of
32
+ # the given string
33
+ def print_header(string)
34
+ header = "\n"
35
+ border = "===="
36
+ string.each_char { border << "=" }
37
+ header << border + "\n"
38
+ header << "= " + string + " =\n"
39
+ header << border +"\n"
40
+ log_print header
41
+ end #print_header
42
+
43
+ # download_and_decompress
44
+ # Delegates the download and decompression duties
45
+ def download_and_decompress(prefix)
46
+ print_header "Downloading and Decompressing"
47
+ downloads = 0
48
+ Constants::URLS.each do |url|
49
+ if !File.exists?("#{ get_tarball_name url }") ||
50
+ !File.exists?("#{ get_version url }")
51
+ wget_download prefix, url
52
+ decompress prefix, url
53
+ downloads += 1
54
+ end #if
55
+ end #do
56
+ end #download_and_decompress
57
+
58
+ # wget_download
59
+ # Takes a URL and the name of a tarball and issues a wget command on said
60
+ # URL unless the tarball or directory already exists
61
+ def wget_download(prefix, url)
62
+ if !File.exists?("#{ prefix }/#{ get_tarball_name url }") &&
63
+ !File.directory?("#{ prefix }/#{ get_version url }")
64
+ cmd "wget -P #{ prefix } #{ url }"
65
+ end #if
66
+ end #wget_download
67
+
68
+ # decompress
69
+ # Decompress downloaded files unless already decompressed directory
70
+ # exists
71
+ def decompress(prefix, url)
72
+ tarball = get_tarball_name(url)
73
+ dir = get_version(url)
74
+ cmd "tar -xzf #{ prefix }/#{ tarball } -C #{ prefix }" unless
75
+ File.directory? "#{ prefix }/#{ dir }"
76
+ end #decompress
77
+
78
+ # get_version
79
+ # This method extracts the untarballed name of files retrieved via wget
80
+ # from their URL
81
+ def get_version(url)
82
+ url =~ /.*\/(.*)\.t.*\Z/
83
+ $1
84
+ end #get_version
85
+
86
+ # get_tarball_name
87
+ # This method extracts the name of files retrieved via wget from their URL
88
+ def get_tarball_name(url)
89
+ url =~ /.*\/(.*\.t.*)/
90
+ $1
91
+ end #get_tarball_name
92
+
93
+ # cleanup
94
+ # This method moves all compressed files from the installation directory
95
+ # that were downloaded by this installation process
96
+ def cleanup(options)
97
+ prefix = options[:prefix]
98
+
99
+ print_header "Cleaning up"
100
+
101
+ Dir.mkdir("#{prefix}/downloads") unless File.directory?("#{prefix}/downloads")
102
+ Constants::URLS.each do |url|
103
+ file = get_version url
104
+ if File.exists?("#{prefix}/#{file}")
105
+ cmd "rm -rf #{prefix}/downloads/#{file}"
106
+ cmd "mv #{prefix}/#{file}* #{prefix}/downloads"
107
+ end #if
108
+ end # do
109
+ end #cleanup
110
+ end #Utilities
@@ -0,0 +1,55 @@
1
+ #!/opt/rhoconnect/bin/ruby
2
+
3
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "scripts"))
4
+
5
+ require 'logger'
6
+ require 'time'
7
+ require 'rho_connect_install_constants'
8
+ require 'rho_connect_install_utilities'
9
+
10
+ include Utilities
11
+
12
+ # Simplify logger output format: [timestamp] message
13
+ class Logger
14
+ class Formatter
15
+ #Format = "[%s] %s\n"
16
+ def call(severity, time, progname, msg)
17
+ "[%s] %s\n" % [format_datetime(time), msg]
18
+ end
19
+ end
20
+ end
21
+
22
+ # set necessary variables
23
+ @options = {:prefix => Constants::DEFAULT_INSTALL_DIR,
24
+ :dist => "debian",
25
+ :pkg_mgr => 'apt-get -y',
26
+ :pkg_chkr => 'dpkg -l',
27
+ :start_dir => `pwd`.strip,
28
+ :web_server => Constants::WEB_SERVER}
29
+
30
+ log = Logger.new(IO.readlines("#{@options[:prefix]}/info.dat").last.strip)
31
+ log.datetime_format = "%Y-%m-%d %H:%M:%S" # simplify time output
32
+
33
+ # execute_installation
34
+ # This method orchestrates the actual installation process
35
+ def execute_installation
36
+ install_sqlite @options
37
+
38
+ # Start installing
39
+ install_all_gems @options
40
+ configure_passenger @options
41
+
42
+ # Install Redis
43
+ install_redis @options
44
+
45
+ # Install rhoconnect
46
+ install_rhoconnect @options
47
+
48
+ # Remove downloaded tarballs and extracted directories
49
+ cleanup @options
50
+ end #execute_installation
51
+
52
+ # Start installation process
53
+ download_and_decompress @options[:prefix]
54
+
55
+ execute_installation
@@ -0,0 +1,67 @@
1
+ Thank you for choosing Rhomobile for your cross-platform app needs!
2
+ To finish this setup, please complete the following...
3
+
4
+ 1) Add necessary bins to the path(s) of the users who will
5
+ be using this software. You may also wish to add these items
6
+ to ~/.profile to automatically add them upon login.
7
+ Ex:
8
+
9
+ A) All bins in the main bin deposit:
10
+ export PATH=/opt/rhoconnect/bin:$PATH
11
+
12
+ B) Bins specifically placed in the ruby/bin directory
13
+ export PATH=/opt/rhoconnect/ruby/1.8/bin:$PATH
14
+
15
+ Or if you had other versions of ruby installed previously to running
16
+ this installation, you may instead wish to simply create an alias
17
+ for the newly installed ruby.
18
+
19
+ Ex:
20
+ alias rubyee=/opt/rhoconnect/bin/ruby
21
+
22
+ B) Add the export line to ~/.profile:
23
+ export PATH=/opt/rhoconnect/bin:opt/rhoconnect/ruby/bin:$PATH
24
+
25
+ 2) Rhoconnect installer configured redis server with the following settings:
26
+
27
+ A) redis.conf file is located in /opt/rhoconnect/etc/ directory with properties:
28
+ daemonize yes
29
+ pidfile /var/run/redis.pid
30
+ logfile /var/log/redis.log
31
+
32
+ B) Redis logrotate settings for /var/log/redis.log files defined in '/etc/logrotate.d/redis':
33
+
34
+ /var/log/redis.log {
35
+ rotate 3
36
+ missingok
37
+ notifempty
38
+ size 250k
39
+ create 0644 root root
40
+ compress
41
+ }
42
+
43
+ C) Redis start-up script '/etc/init.d/redis'.
44
+ You can start/stop redis server by running the following commands:
45
+ /etc/init.d/redis {start|stop}
46
+
47
+ 3) Setup rhoconnect application directory
48
+    
49
+ A) Put your application code in a directory called /var/www/rhoconnect
50
+ (make sure this is the root of your applictaion directory, i.e. /var/www/rhoconnect/config.ru should exist).
51
+
52
+ B) Make an empty public folder in the directory
53
+ $ mkdir /var/www/rhoconnect/public
54
+
55
+ 4) Configure Apache2
56
+ A) Configure virtual host for rhoconnect application:
57
+ Edit the file /etc/apache2/sites-available/rhoconnect so that it
58
+ reflects your specifications.
59
+
60
+ B) Enable the virtual host:
61
+ $ sudo a2ensite rhoconnect
62
+
63
+ C) Load the passenger.load module
64
+ $ sudo a2enmod passenger
65
+
66
+ D) Restart apache to pick up the changes:
67
+ $ sudo /etc/init.d/apache2 restart