pointer 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,7 +10,7 @@ configures mina for deployment, deploys a simple application that exposes a WebH
10
10
 
11
11
  ## Assumptions (for now)
12
12
 
13
- * You have a clean Ubuntu 12.10 Server (no installations of nginx, rvm or anything, just clean server)
13
+ * You have a clean Ubuntu 12.10 Server (no installations of nginx, rvm or anything, just clean server) - try DigitalOcean.com (5$/month for 512MB/20GB SSD)
14
14
  * You have root password to that server
15
15
  * You are ok to use RVM, nginx/Passenger (no Apache yet), mina (no Capistrano yet) to Production
16
16
  * You need a Postgres database on Production
data/TODO.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  vagrant for tests
4
4
  touch: cannot touch `tmp/restart.txt': No such file or directory (via deploy)
5
-
6
5
  automate bitbicket deployment key installation
7
6
  что если nginx уже поставлен?
8
7
  support apache
@@ -21,16 +20,24 @@ Fix locales (/etc/environment) on Ubuntu
21
20
  что может пойти не так с публично доступным deploy? add md5=...
22
21
  remove all https://raw.github.com/slava-vishnyakov/useful-stuff/master/init.d-nginx.conf
23
22
  detect bitbucket keys https://bitbucket.org/username/test2/admin/deploy-keys
24
-
25
23
  once installed postgres will not allow second creation
26
24
  local git hosting on server? bad idea, but really easy
27
-
28
25
  @ssh.exec! -> expect_success
29
26
  session identifier shared
30
27
  "your website is at"
31
-
32
28
  check for gem pg in Gemfile
33
-
29
+ publish without git? local deploy?
30
+ add info on "Use this as deploy key"
31
+ gitignored /shared folder to upload shared files?
32
+ remove application, rename
34
33
  backups?
34
+ --use-existing-mina
35
+ check prereqs: postgres use can connect (bug: same host => same user, cannot connect!)
36
+ check prereqs: allowed to connect to host in paranoia mode (known hosts)
37
+
38
+ nginx.conf: http { server_names_hash_bucket_size 512;
39
+
40
+ The authenticity of host 'revolver3.slava.io (198.211.118.58)' can't be established. - не ломает приложение
41
+ CRITICAL: когда меняется deploy.rb или он не закоммичен - нужно загружать его и рестартовать deployer - может даже симлинк на SCM/deploy.rb? double deploy если поменялся? scp upload вместо деплоя?
35
42
 
36
- publish without git? local deploy?
43
+ PermitRootLogin запретить
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'pointer'
4
+ require 'fileutils'
4
5
 
5
6
  config_file = 'config/pointer.rb'
6
7
 
@@ -0,0 +1,31 @@
1
+ #!/bin/bash -e
2
+
3
+ source `dirname $0`/variables.sh
4
+
5
+ if ! id -u $RAILS_USER >/dev/null 2>&1; then
6
+ echo "Create rails user: $RAILS_USER"
7
+ useradd rails -d /home/$RAILS_USER -m -s /bin/bash
8
+ usermod -a -G sudo $RAILS_USER
9
+ fi
10
+
11
+ SSH_DIR="/home/$RAILS_USER/.ssh"
12
+ AUTHORIZED_KEYS_FILE="$SSH_DIR/authorized_keys"
13
+
14
+ # def upload_public_key
15
+ if [[ ! -e $SSH_DIR ]]; then
16
+ mkdir $SSH_DIR
17
+ chown $RAILS_USER:$RAILS_USER $SSH_DIR
18
+ chmod 0700 $SSH_DIR
19
+ fi
20
+
21
+ if [[ ! -e $AUTHORIZED_KEYS_FILE ]]; then
22
+ touch $AUTHORIZED_KEYS_FILE
23
+ chown $RAILS_USER:$RAILS_USER $AUTHORIZED_KEYS_FILE
24
+ chmod 0600 $AUTHORIZED_KEYS_FILE
25
+ fi
26
+
27
+ echo "Uploading private key"
28
+ cat $PUBLIC_KEY >> $AUTHORIZED_KEYS_FILE
29
+
30
+ echo "Give sudo rights"
31
+ echo "$RAILS_USER ALL = NOPASSWD:ALL" >> /etc/sudoers
@@ -0,0 +1,279 @@
1
+ #!/bin/bash -e
2
+
3
+ source `dirname $0`/variables.sh
4
+
5
+ if [[ `whoami` != $RAILS_USER ]]; then
6
+ echo "Please run this as $RAILS_USER"
7
+ exit
8
+ fi
9
+
10
+ LOG_FILE=/home/$RAILS_USER/pointer.log
11
+
12
+ (cat /etc/environment | grep "LC_ALL=en_US.UTF-8") || (
13
+ echo "LC_ALL=en_US.UTF-8" | sudo tee -a /etc/environment
14
+ echo "LANG=en_US.UTF-8" | sudo tee -a /etc/environment
15
+ sudo locale-gen en_US en_US.UTF-8 >> $LOG_FILE 2>> $LOG_FILE
16
+ sudo dpkg-reconfigure locales >> $LOG_FILE 2>> $LOG_FILE
17
+ )
18
+
19
+ if [[ ! -e /home/$RAILS_USER/.rvm/scripts/rvm ]]; then
20
+ echo "Update system"
21
+ sudo apt-get -qq -y update >> $LOG_FILE 2>> $LOG_FILE
22
+
23
+ echo "Install RVM deps"
24
+ sudo apt-get -qq -y install curl libcurl4-gnutls-dev git nodejs build-essential openssl \
25
+ libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev \
26
+ libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf \
27
+ libc6-dev ncurses-dev automake libtool bison subversion pkg-config libgdbm-dev libffi-dev >> $LOG_FILE 2>> $LOG_FILE
28
+
29
+ echo "Install RVM"
30
+ curl -L https://get.rvm.io | bash -s stable --ruby=1.9.3 >> $LOG_FILE 2>> $LOG_FILE
31
+ fi
32
+
33
+ source "/home/$RAILS_USER/.rvm/scripts/rvm"
34
+
35
+ echo "Use 1.9.3"
36
+ rvm use 1.9.3 --default >> $LOG_FILE 2>> $LOG_FILE
37
+
38
+ echo "gem: --no-ri --no-rdoc" >> /home/$RAILS_USER/.gemrc
39
+
40
+ echo "Install Passenger"
41
+
42
+ if [[ ! -e /opt/nginx/conf/rails-sites ]]; then
43
+ (gem list | grep passenger) > /dev/null || gem install passenger >> $LOG_FILE 2>> $LOG_FILE
44
+
45
+ if [[ ! -e /opt/nginx ]]; then
46
+ sudo mkdir -p /opt/nginx
47
+ fi
48
+ sudo chown $RAILS_USER:$RAILS_USER /opt/nginx
49
+ passenger-install-nginx-module --auto --auto-download --prefix=/opt/nginx >> $LOG_FILE 2>> $LOG_FILE
50
+
51
+ echo "Installing nginx init.d"
52
+ sudo wget https://raw.github.com/slava-vishnyakov/useful-stuff/master/init.d-nginx.conf -O /etc/init.d/nginx >> $LOG_FILE 2>> $LOG_FILE
53
+
54
+ echo "Changing nginx.conf permissions"
55
+ sudo chmod o+x /etc/init.d/nginx
56
+
57
+ echo "update-rc.d"
58
+ sudo update-rc.d nginx defaults >> $LOG_FILE 2>> $LOG_FILE
59
+
60
+ echo "Installing nginx.conf"
61
+ mv /opt/nginx/conf/nginx.conf /opt/nginx/conf/nginx.conf-orig
62
+ wget https://raw.github.com/slava-vishnyakov/useful-stuff/master/nginx.conf -O /opt/nginx/conf/nginx.conf >> $LOG_FILE 2>> $LOG_FILE
63
+
64
+ echo "Replacing passenger_ruby and passenger_root with actual Passenger data"
65
+ ruby -e "
66
+ orig_file = IO.read '/opt/nginx/conf/nginx.conf-orig';
67
+ new_file = IO.read '/opt/nginx/conf/nginx.conf';
68
+ new_file.sub! /passenger_ruby (.*?);/, orig_file.match(/passenger_ruby (.*?);/)[0];
69
+ new_file.sub! /passenger_root (.*?);/, orig_file.match(/passenger_root (.*?);/)[0];
70
+ IO.write '/opt/nginx/conf/nginx.conf', new_file
71
+ "
72
+
73
+ echo "Creating /opt/nginx/conf/rails-sites"
74
+ mkdir /opt/nginx/conf/rails-sites
75
+
76
+ echo "Starting nginx"
77
+ sudo service nginx start >> $LOG_FILE 2>> $LOG_FILE
78
+ fi
79
+
80
+ ### PASSENGER INSTALLED
81
+
82
+ (cat /etc/hosts | grep " $SITE_HOST") || (echo "127.0.0.1 $SITE_HOST" | sudo tee -a /etc/hosts >> $LOG_FILE 2>> $LOG_FILE)
83
+
84
+ NGINX_CONFIG="
85
+ server {\n
86
+ listen $SITE_PORT;\n
87
+ server_name $SITE_HOST;\n
88
+ passenger_enabled on;\n
89
+ root $SITE_DIR/current/public;\n
90
+ passenger_user rails;\n
91
+ passenger_max_requests 500;\n
92
+ }\n
93
+ "
94
+
95
+ CONFIG_FILE="/opt/nginx/conf/rails-sites/$SITE_HOST-$SITE_PORT.conf"
96
+
97
+ echo -e $NGINX_CONFIG > $CONFIG_FILE
98
+
99
+ (sudo /opt/nginx/sbin/nginx -t >> $LOG_FILE 2>> $LOG_FILE) && sudo service nginx reload
100
+
101
+ ## SITE CONFIG INSTALLED
102
+
103
+ if [[ ! -e $SITE_DIR/data ]]; then
104
+ mkdir -p $SITE_DIR/data
105
+ fi
106
+
107
+ (gem list | grep mina) > /dev/null || gem install mina >> $LOG_FILE 2>> $LOG_FILE
108
+
109
+ if [[ ! -e $SITE_DIR/data/config/deploy.rb ]]; then
110
+ cd $SITE_DIR/data && mina init < /dev/null
111
+ fi
112
+
113
+
114
+ RVM_PROMPT=`rvm-prompt`
115
+
116
+ sed -i "s!# require 'mina/rvm'!require 'mina/rvm'!" $SITE_DIR/data/config/deploy.rb
117
+ sed -i "s!set :domain, 'foobar\.com'!set :domain, '$SITE_HOST'!" $SITE_DIR/data/config/deploy.rb
118
+ sed -i "s!set :deploy_to, '/var/www/foobar\.com'!set :deploy_to, '$SITE_DIR'!" $SITE_DIR/data/config/deploy.rb
119
+ sed -i "s!# set :user, 'foobar'! set :user, '$RAILS_USER'!" $SITE_DIR/data/config/deploy.rb
120
+ sed -i "s!# invoke :'rvm:use\[ruby-1\.9\.3-p125@default\]'!invoke :'rvm:use[$RVM_PROMPT]'!" $SITE_DIR/data/config/deploy.rb
121
+ sed -i "s!queue %\[-----> Be sure to edit 'shared/config/database\.yml'\.\]!!" $SITE_DIR/data/config/deploy.rb
122
+ sed -i "s!set :repository, 'git://\.\.\.'!set :repository, '$REMOTE_REPO'!" $SITE_DIR/data/config/deploy.rb
123
+ sed -i "s!set :shared_paths, \['config/database.yml', 'log'\]!set :shared_paths, ['config/database.yml', 'log', 'tmp']!" $SITE_DIR/data/config/deploy.rb
124
+
125
+ # cat $SITE_DIR/data/config/deploy.rb
126
+
127
+ if [[ ! -e $SITE_DIR/shared/tmp/ ]]; then
128
+ mkdir -p $SITE_DIR/shared/tmp
129
+ touch $SITE_DIR/shared/tmp/restart.txt
130
+ fi
131
+
132
+ # INSTALL POSTGRES
133
+
134
+ # unless @ssh.exec! 'which psql'
135
+ # official apt repo does not support 12.10 (quantal) yet :(
136
+ which psql || (
137
+ echo "Installing PostgreSQL..."
138
+ sudo apt-get install -y libpq-dev >> $LOG_FILE 2>> $LOG_FILE
139
+ sudo apt-get install -y software-properties-common >> $LOG_FILE 2>> $LOG_FILE
140
+ sudo add-apt-repository ppa:pitti/postgresql < /dev/null >> $LOG_FILE 2>> $LOG_FILE
141
+ sudo apt-get update >> $LOG_FILE 2>> $LOG_FILE
142
+ sudo apt-get install -y postgresql-9.2 >> $LOG_FILE 2>> $LOG_FILE
143
+ )
144
+
145
+ if [[ ! -e $SITE_DIR/data/.postgres ]]; then
146
+ echo "Generating PostgreSQL user"
147
+ USERNAME=user_`echo "$SITE_HOST.$SITE_PORT" | sed -e 's/[^a-z0-9A-Z]/_/g'`
148
+ DATABASE=database_`echo "$SITE_HOST.$SITE_PORT" | sed -e 's/[^a-z0-9A-Z]/_/g'`
149
+ PASSWORD=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32}`
150
+
151
+ echo -e "USERNAME=$USERNAME\nDATABASE=$DATABASE\nPASSWORD=$PASSWORD" > $SITE_DIR/data/.postgres
152
+ chmod 0700 $SITE_DIR/data/.postgres
153
+
154
+ sudo sudo -u postgres psql -c "CREATE ROLE $USERNAME WITH CREATEDB LOGIN PASSWORD '$PASSWORD'" >> $LOG_FILE 2>> $LOG_FILE
155
+ sudo sudo -u postgres psql -c "CREATE DATABASE $DATABASE OWNER $USERNAME" >> $LOG_FILE 2>> $LOG_FILE
156
+ fi
157
+
158
+ if [[ ! -e $SITE_DIR/shared/config ]]; then
159
+ mkdir -p $SITE_DIR/shared/config
160
+ fi
161
+
162
+ if [[ ! -e $SITE_DIR/shared/config/database.yml ]]; then
163
+ . $SITE_DIR/data/.postgres
164
+
165
+ DATABASE_YML="production:
166
+ adapter: postgresql
167
+ host: 127.0.0.1
168
+ encoding: utf8
169
+ database: $DATABASE
170
+ username: $USERNAME
171
+ password: $PASSWORD
172
+ "
173
+
174
+ echo -e "$DATABASE_YML" > "$SITE_DIR/shared/config/database.yml"
175
+ fi
176
+
177
+
178
+ echo "Generate SSH key and add it to trusted"
179
+ if [[ ! -e /home/$RAILS_USER/.ssh/id_rsa ]]; then
180
+ ssh-keygen -q -t rsa -f /home/$RAILS_USER/.ssh/id_rsa -N '' >> $LOG_FILE 2>> $LOG_FILE
181
+ cat /home/$RAILS_USER/.ssh/id_rsa.pub >> /home/$RAILS_USER/.ssh/authorized_keys
182
+ ssh -o StrictHostKeyChecking=no $RAILS_USER@$SITE_HOST -p $SSH_PORT 'echo "OK"' >> $LOG_FILE 2>> $LOG_FILE
183
+ fi
184
+
185
+ echo "------ Use this as deployment key ------"
186
+ cat /home/$RAILS_USER/.ssh/id_rsa.pub
187
+ echo "------ END ------"
188
+
189
+ if [[ $BITBUCKET ]]; then
190
+ echo "Please add this key on BitBucket as you Deployment Key [BitBucket -> Your repository -> Gear Icon -> Deployment keys]..."
191
+ echo "The installer will continue as soon as key is saved (it might take up to a minute)"
192
+ FAIL=`ssh -o StrictHostKeyChecking=no git@bitbucket.org ls 2> /dev/null </dev/null || echo FAIL`
193
+ while [[ $FAIL == 'FAIL' ]]; do
194
+ FAIL=`ssh -o StrictHostKeyChecking=no git@bitbucket.org ls 2> /dev/null </dev/null || echo FAIL`
195
+ sleep 1
196
+ echo -n '.'
197
+ done
198
+ echo "Key detected!"
199
+ fi
200
+
201
+ #### MINA
202
+
203
+ if [[ ! -e $SITE_DIR/data/.mina_setup_done ]]; then
204
+ echo "Doing mina setup"
205
+ cd $SITE_DIR/data/ && (mina setup < /dev/null >> $LOG_FILE 2>> $LOG_FILE)
206
+ touch $SITE_DIR/data/.mina_setup_done
207
+ fi
208
+
209
+ echo "Doing the first deploy"
210
+ cd $SITE_DIR/data/ && (mina deploy < /dev/null >> $LOG_FILE 2>> $LOG_FILE)
211
+
212
+ ### DEPLOYER APP
213
+
214
+ echo "Installing webhook"
215
+ (gem list | grep sinatra) > /dev/null || gem install sinatra >> $LOG_FILE 2>> $LOG_FILE
216
+
217
+ mkdir -p $SITE_DIR/webhook_application/public
218
+
219
+ which bc || sudo apt-get -qq -y install bc >> $LOG_FILE 2>> $LOG_FILE
220
+
221
+ DEPLOYER_PORT=`echo "$SITE_PORT+810" | bc`
222
+
223
+ NGINX_CONFIG="server {\n
224
+ listen $DEPLOYER_PORT;\n
225
+ server_name $SITE_HOST;\n
226
+ passenger_enabled on;\n
227
+ passenger_user $RAILS_USER;\n
228
+ passenger_max_requests 1;\n
229
+ root $SITE_DIR/webhook_application/public;\n}"
230
+
231
+ if [[ ! -e $SITE_DIR/data/.deployer_app ]]; then
232
+ CODE=`< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${1:-32}`
233
+ echo -e "CODE=$CODE" > $SITE_DIR/data/.deployer_app
234
+ chmod 0700 $SITE_DIR/data/.deployer_app
235
+ fi
236
+
237
+ . $SITE_DIR/data/.deployer_app
238
+
239
+ echo -e $NGINX_CONFIG > "/opt/nginx/conf/rails-sites/deployer-$SITE_HOST-$DEPLOYER_PORT.conf"
240
+
241
+ CONFIG_RU="\n
242
+ require 'sinatra'\n
243
+ \n
244
+ post '/deploy/$CODE' do\n
245
+ \`cd / && mina -f $SITE_DIR/data/config/deploy.rb deploy < /dev/null\`\n
246
+ end\n
247
+ \n
248
+ run Sinatra::Application\n
249
+ "
250
+
251
+ # TODO: detect commited config/deploy.rb
252
+ # TODO: if deploy.rb cahnged - double deploy
253
+
254
+ echo -e $CONFIG_RU > "$SITE_DIR/webhook_application/config.ru"
255
+ sudo service nginx restart >> $LOG_FILE 2>> $LOG_FILE
256
+
257
+ HOOK_URL="http://$SITE_HOST:$DEPLOYER_PORT/deploy/$CODE"
258
+
259
+ echo -e "---------------------\n\n\n"
260
+ echo "Your setup is DONE"
261
+ echo ""
262
+ echo "-------"
263
+ echo "WebHook (POST) address: $HOOK_URL"
264
+ echo "Add this to GitHub/BitBucket as WebHook/POST service, so that your code is automatically deployed on every push"
265
+ echo "Run, for example:"
266
+ echo "curl -X POST $HOOK_URL"
267
+ echo "-------"
268
+ echo
269
+ echo "------ Use this as deployment key ------"
270
+ cat /home/$RAILS_USER/.ssh/id_rsa.pub
271
+ echo "------ END ------"
272
+ echo
273
+ echo "Your app should be available on http://$SITE_HOST:$SITE_PORT/"
274
+ echo
275
+ echo "If you have any problems visit: https://github.com/slava-vishnyakov/pointer/issues"
276
+ echo
277
+ echo "- Slava"
278
+
279
+
@@ -15,13 +15,14 @@ set :ssh_host, host
15
15
 
16
16
  set :ssh_user, 'root'
17
17
  set :ssh_port, 22
18
- set :password, 'password_of_root'
19
18
 
20
19
  # Your public and private key that will be used for deployment
21
20
 
22
21
  set :public_key, "~/.ssh/id_rsa.pub"
23
22
  set :private_key, "~/.ssh/id_rsa"
24
23
 
24
+ set :git_repo, 'git@bitbucket.org:repo/repo.git'
25
+
25
26
  # Less privileged user that you will use to deploy the project
26
27
 
27
28
  rails_user = 'rails'
@@ -33,11 +34,6 @@ set :site_host, host
33
34
  set :site_port, 80
34
35
  set :site_dir, "/home/#{rails_user}/applications/#{host}"
35
36
 
36
- # Do we plan to host your site on BitBucket?
37
- # BitBucket is the only reputable repo hosting that I know that allows free private repositories
38
-
39
- set :git_repo, 'git@bitbucket.org:repo/repo.git'
40
-
41
37
  # Currently only NginxPassenger is supported
42
38
  # in future :apache will be supported too
43
39
 
@@ -0,0 +1,10 @@
1
+ RAILS_USER=<%= @options[:rails_user].inspect %>
2
+ PUBLIC_KEY='<%= remote_public_key_file %>'
3
+ SITE_PORT=<%= @options[:site_port].inspect %>
4
+ SITE_HOST=<%= @options[:site_host].inspect %>
5
+ SITE_DIR=<%= @options[:site_dir].inspect %>
6
+ REMOTE_REPO=<%= @options[:git_repo].inspect %>
7
+ SSH_PORT=<%= @options[:ssh_port].inspect %>
8
+ <% if bitbucket %>
9
+ BITBUCKET=1
10
+ <% end %>
@@ -1,73 +1,73 @@
1
1
  require "pointer/version"
2
- require 'active_support/secure_random'
3
-
4
- Dir[File.expand_path(File.dirname(__FILE__) + '/pointer/**.rb')].each do |file|
5
- require file
6
- end
2
+ require 'read-password'
3
+ require 'erb'
4
+ require 'net/ssh'
5
+ require 'net/scp'
6
+ require 'tempfile'
7
7
 
8
8
  module Pointer
9
9
  class EasyDeploy
10
- include Postgres
11
- include Helpers
12
- include Variables
13
- include SshHelpers
14
- include BitBucket
15
- include DeployerApplication
16
- include Mina
17
- include NginxPassenger
18
- include RailsUser
19
- include Rvm
10
+ def remote_private_key_file
11
+ "/tmp/tmp_private_key"
12
+ end
20
13
 
21
- def run!(options)
22
- @options = options
14
+ def remote_public_key_file
15
+ "/tmp/tmp_private_key"
16
+ end
23
17
 
24
- assert_git()
25
- check_mina_prereqs()
18
+ def bitbucket
19
+ @options[:git_repo].include? '@bitbucket.org:'
20
+ end
26
21
 
27
- with_root_ssh do
28
- # delete_rails_user()
29
- create_rails_user()
30
- upload_public_key()
31
- add_sudo()
22
+ def run!(options)
23
+ @options = options
24
+ @options[:ssh_password] = Kernel.password("ssh password for user #{@options[:ssh_user]}: ")
25
+ variables = ERB.new(IO.read(File.dirname(__FILE__) + '/../config/variables.sh.erb'))
26
+
27
+ var_file = Tempfile.new('sh')
28
+ var_file.write(variables.result(binding))
29
+ var_file.rewind
30
+
31
+ Net::SSH.start(@options[:ssh_host], @options[:ssh_user], password: @options[:ssh_password], paranoid: false) do |ssh|
32
+ puts ssh.scp.upload!(var_file.path, '/tmp/variables.sh')
33
+ puts ssh.scp.upload!(File.expand_path(@options[:public_key]), remote_public_key_file)
34
+ puts ssh.scp.upload!(File.dirname(__FILE__) + '/../config/1_as_root.sh', '/tmp/1.sh')
35
+ puts ssh.scp.upload!(File.dirname(__FILE__) + '/../config/2_as_rails.sh', '/tmp/2.sh')
36
+ run_stream('bash -l -e /tmp/1.sh', ssh)
37
+
38
+ puts ssh.exec!("chown #{@options[:rails_user]}:#{@options[:rails_user]} /tmp/variables.sh")
39
+ puts ssh.exec!("chown #{@options[:rails_user]}:#{@options[:rails_user]} " + remote_public_key_file)
40
+ puts ssh.exec!("chown #{@options[:rails_user]}:#{@options[:rails_user]} /tmp/1.sh")
41
+ puts ssh.exec!("chown #{@options[:rails_user]}:#{@options[:rails_user]} /tmp/2.sh")
32
42
  end
33
43
 
34
- with_ssh do
35
- test_connection()
36
-
37
- install_rvm()
38
-
39
- if nginx
40
- install_passenger()
41
- create_site_config()
42
- end
44
+ Net::SSH.start(@options[:ssh_host], @options[:rails_user], keys: File.expand_path(@options[:private_key]), paranoid: false) do |ssh|
43
45
 
44
- if mina
45
- mina_init()
46
- end
47
-
48
- if postgres
49
- @db_config = install_postgres()
50
- end
51
-
52
- print_deploy_key()
46
+ run_stream('bash -l -e /tmp/2.sh', ssh)
47
+ puts "ok"
48
+ end
49
+ ensure
50
+ Net::SSH.start(@options[:ssh_host], @options[:ssh_user], password: @options[:ssh_password], paranoid: false) do |ssh|
51
+ puts ssh.exec!('rm /tmp/variables.sh')
52
+ puts ssh.exec!('rm ' + remote_public_key_file)
53
+ puts ssh.exec!('rm /tmp/1.sh')
54
+ puts ssh.exec!('rm /tmp/2.sh')
55
+ end
56
+ end
53
57
 
54
- if bitbucket
55
- add_bit_bucket_host()
56
- end
58
+ def run_stream(cmd, ssh)
59
+ ssh.exec! cmd do |ch, success|
60
+ raise "could not execute command" unless success
57
61
 
58
- if mina
59
- mina_deploy()
62
+ ch.on_data do |c, data|
63
+ STDOUT.print data
60
64
  end
61
65
 
62
- if deployer_application
63
- install_deployer()
66
+ ch.on_extended_data do |c, type, data|
67
+ STDERR.print data
64
68
  end
65
-
66
- revoke_sudo()
67
69
  end
68
70
  end
69
-
70
-
71
71
  end
72
72
  end
73
73
 
@@ -1,3 +1,3 @@
1
1
  module Pointer
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -23,6 +23,5 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency "net-ssh"
25
25
  spec.add_dependency "net-scp"
26
- spec.add_dependency "colorize"
27
- spec.add_dependency "active_support"
26
+ spec.add_dependency "read-password"
28
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pointer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-26 00:00:00.000000000 Z
12
+ date: 2013-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -76,23 +76,7 @@ dependencies:
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
- name: colorize
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :runtime
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: active_support
79
+ name: read-password
96
80
  requirement: !ruby/object:Gem::Requirement
97
81
  none: false
98
82
  requirements:
@@ -122,18 +106,11 @@ files:
122
106
  - Rakefile
123
107
  - TODO.md
124
108
  - bin/pointer
109
+ - config/1_as_root.sh
110
+ - config/2_as_rails.sh
125
111
  - config/pointer.rb.default
112
+ - config/variables.sh.erb
126
113
  - lib/pointer.rb
127
- - lib/pointer/bit_bucket.rb
128
- - lib/pointer/deployer_application.rb
129
- - lib/pointer/helpers.rb
130
- - lib/pointer/mina.rb
131
- - lib/pointer/nginx_passenger.rb
132
- - lib/pointer/postgres.rb
133
- - lib/pointer/rails_user.rb
134
- - lib/pointer/rvm.rb
135
- - lib/pointer/ssh_helpers.rb
136
- - lib/pointer/variables.rb
137
114
  - lib/pointer/version.rb
138
115
  - pointer.gemspec
139
116
  homepage: ''
@@ -151,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
128
  version: '0'
152
129
  segments:
153
130
  - 0
154
- hash: 3479741334444265196
131
+ hash: 2754358321784396675
155
132
  required_rubygems_version: !ruby/object:Gem::Requirement
156
133
  none: false
157
134
  requirements:
@@ -160,10 +137,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
137
  version: '0'
161
138
  segments:
162
139
  - 0
163
- hash: 3479741334444265196
140
+ hash: 2754358321784396675
164
141
  requirements: []
165
142
  rubyforge_project:
166
- rubygems_version: 1.8.25
143
+ rubygems_version: 1.8.23
167
144
  signing_key:
168
145
  specification_version: 3
169
146
  summary: Quick deploy
@@ -1,25 +0,0 @@
1
- module Pointer
2
- module BitBucket
3
- def add_bit_bucket_host()
4
- what "Use this as deploy key"
5
- puts '----'
6
- puts get_file_contents('/home/rails/.ssh/id_rsa.pub')
7
- puts '----'
8
-
9
- if bitbucket
10
- if @ssh.exec!('bash -lc "ssh -o StrictHostKeyChecking=no git@bitbucket.org"') =~ /Permission denied/
11
- puts "Press ENTER when you added this deploy key to repository".red
12
- STDIN.readline()
13
- end
14
- else
15
- puts "You need to ssh into your machine as 'ssh #{rails_user}@#{host} -p #{port}'"
16
- puts "then connect via ssh to your repository hosting, like so 'ssh git@github.com' and accept the key"
17
- puts "Then you need to install the deploy key above"
18
- puts "Press ENTER when you added this deploy key to repository".red
19
- STDIN.readline()
20
- end
21
- end
22
-
23
-
24
- end
25
- end
@@ -1,52 +0,0 @@
1
- module Pointer
2
- module DeployerApplication
3
- def install_deployer()
4
- deployer_port = site_port.to_i + 8000
5
- # TODO: detect if mina and sinatra already installed
6
- puts rvm! "gem install mina"
7
- puts rvm! "gem install sinatra"
8
-
9
- local_key = get_file_contents('/home/rails/.ssh/id_rsa.pub')
10
- ensure_file_contains("/home/rails/.ssh/authorized_keys", local_key)
11
- puts @ssh.exec! "ssh -o StrictHostKeyChecking=no rails@#{host} pwd"
12
-
13
- puts @ssh.exec! "mkdir -p applications/pointer/#{host}-#{site_port}/public"
14
-
15
-
16
- server = "
17
- server {
18
- listen #{deployer_port};
19
- server_name #{host};
20
- passenger_enabled on;
21
- passenger_user rails;
22
- passenger_max_requests 10;
23
- root /home/rails/applications/pointer/#{host}-#{site_port}/public;
24
- }
25
- "
26
-
27
- put_file_contents("/opt/nginx/conf/rails-sites/pointer-#{host}-#{deployer_port}.conf", server)
28
-
29
- mtime = "#{host}-#{site_port}"
30
- config_ru = "
31
- require 'sinatra'
32
-
33
- post '/deploy/#{mtime}' do
34
- `cd / && mina -f /home/rails/applications/pointer/#{host}-#{site_port}/deploy.rb deploy` # < /dev/null > /dev/null && echo OK
35
- end
36
-
37
- run Sinatra::Application
38
- "
39
-
40
- put_file_contents("applications/pointer/#{host}-#{site_port}/deploy.rb", IO.read('./config/deploy.rb'))
41
- put_file_contents("applications/pointer/#{host}-#{site_port}/config.ru", config_ru)
42
- puts @ssh.exec!('sudo service nginx restart')
43
-
44
- hook_url = "http://#{host}:#{deployer_port}/deploy/#{mtime}"
45
- puts "WebHook (POST) address: %s" % [hook_url.green]
46
- puts "Add this to GitHub/BitBucket as WebHook/POST service, so that your code is automatically deployed on every push"
47
- puts "Run, for example: curl -X POST #{hook_url}"
48
- end
49
-
50
-
51
- end
52
- end
@@ -1,23 +0,0 @@
1
- require 'colorize'
2
-
3
- module Pointer
4
- module Helpers
5
- def remote_repo()
6
- `git config --get remote.origin.url`.gsub(/^ssh:\/\/(.*?)\//, '\\1:').strip
7
- end
8
-
9
- def assert_git()
10
- unless File.exists?('.git')
11
- raise "Please run from a Git repository (use private Git hosting from bitbucket.org for example)"
12
- end
13
-
14
- if remote_repo.to_s == ''
15
- raise "This tool assumes you have git remote branch, named #{'origin'.green}"
16
- end
17
- end
18
-
19
- def what(string)
20
- puts "# #{string}".green
21
- end
22
- end
23
- end
@@ -1,89 +0,0 @@
1
- module Pointer
2
- module Mina
3
- def check_mina_prereqs
4
- if File.exists?('config/deploy.rb') and not ARGV.include?('--unlink-mina')
5
- user_has_mina_config()
6
- end
7
- end
8
-
9
- def mina_deploy()
10
- what "[local -> remote] mina setup"
11
-
12
- mina_setup = `mina setup </dev/null || echo "[ERROR]"`
13
- puts mina_setup
14
- if mina_setup.include? '[ERROR]'
15
- raise "mina setup failed"
16
- end
17
-
18
- remote_db_config_file = "#{@options[:site_dir]}/shared/config/database.yml"
19
-
20
- if @db_config
21
- puts "I have a database config, putting it there"
22
- put_file_contents(remote_db_config_file, @db_config)
23
- else
24
- if file_absent(remote_db_config_file)
25
- db_config = IO.read(@options[:site_dir] + "/shared/config/database.yml")
26
- put_file_contents(remote_db_config_file, db_config)
27
- end
28
- end
29
-
30
- what "[local -> remote] mina deploy"
31
-
32
- mina_deploy = `mina deploy </dev/null || echo "[ERROR]"`
33
- puts mina_deploy
34
- if mina_deploy.include? '[ERROR]'
35
- raise "mina deploy failed"
36
- end
37
-
38
- what "done"
39
- end
40
-
41
- def mina_init()
42
- if ARGV.include? '--unlink-mina'
43
- puts "Unlinking mina config".on_red
44
- File.unlink('config/deploy.rb') if File.exists? 'config/deploy.rb'
45
- end
46
-
47
- rvm_version = rvm!('rvm-prompt').strip
48
-
49
- #`gem install mina`
50
- what "[local] mina init"
51
- mina_init = `mina init </dev/null || echo "[ERROR]"`
52
- if mina_init.include? '[ERROR]'
53
- puts mina_init
54
- user_has_mina_config()
55
- end
56
-
57
- config = IO.read('config/deploy.rb')
58
- config = config.gsub("# require 'mina/rvm'", "require 'mina/rvm'")
59
- config = config.gsub("set :domain, 'foobar.com'", "set :domain, #{@options[:site_host].inspect}")
60
- config = config.gsub("set :deploy_to, '/var/www/foobar.com'", "set :deploy_to, #{@options[:site_dir].inspect}")
61
- config = config.gsub("# set :user, 'foobar'", " set :user, '#{rails_user}'")
62
- config = config.gsub("# invoke :'rvm:use[ruby-1.9.3-p125@default]'", "invoke :'rvm:use[#{rvm_version}]'")
63
- config = config.gsub("queue %[-----> Be sure to edit 'shared/config/database.yml'.]", "")
64
- puts "Be sure to edit 'shared/config/database.yml'".on_red
65
- config = config.gsub("set :repository, 'git://...'", "set :repository, #{remote_repo.inspect}",)
66
- #config = config.gsub("set :shared_paths, ['config/database.yml', 'log']", "set :shared_paths, ['log', 'sqlite']",)
67
-
68
- #database_symlink = "\n" +
69
- # ' queue %[rm "#{deploy_to}/current/config/database.yml"]' + "\n" +
70
- # ' queue %[ln -s "#{deploy_to}/shared/config/database.yml" "#{deploy_to}/current/config/database.yml"]' + "\n" +
71
- # #' queue %[cat "#{deploy_to}/shared/config/database.yml"]' + "\n" +
72
- # "\n "
73
- #
74
- #config = config.gsub("queue 'touch tmp/restart.txt'", database_symlink + "queue 'touch tmp/restart.txt'")
75
- config = config.gsub("queue 'touch tmp/restart.txt'", 'queue "mkdir tmp; touch tmp/restart.txt"')
76
- IO.write('config/deploy.rb', config)
77
- # puts "Run #{'mina setup'.red} and #{'mina deploy'.red}"
78
-
79
- `ssh -o StrictHostKeyChecking=no #{rails_user}@#{host} pwd`
80
-
81
- end
82
-
83
- def user_has_mina_config
84
- puts "Run %s if you already have everything set up" % ["mina deploy".green]
85
- puts "or run with --unlink-mina if you want to force mina config generation"
86
- exit
87
- end
88
- end
89
- end
@@ -1,63 +0,0 @@
1
- module Pointer
2
- module NginxPassenger
3
- def install_passenger()
4
- unless file_exists('/opt/nginx')
5
- what 'Install nginx/passenger'
6
- rvm!('gem install passenger')
7
- @ssh.exec!('sudo mkdir /opt')
8
- @ssh.exec!('sudo mkdir /opt/nginx')
9
- @ssh.exec!('sudo chown rails:rails /opt/nginx')
10
- rvm!('passenger-install-nginx-module --auto --auto-download --prefix=/opt/nginx')
11
-
12
- what "Installing nginx init.d"
13
- @ssh.exec!('sudo wget https://raw.github.com/slava-vishnyakov/useful-stuff/master/init.d-nginx.conf -O /etc/init.d/nginx')
14
-
15
- what "Changing nginx.conf permissions"
16
- @ssh.exec!('sudo chmod o+x /etc/init.d/nginx')
17
-
18
- what "update-rc.d"
19
- @ssh.exec!('sudo update-rc.d nginx defaults')
20
-
21
- what "Installing nginx.conf"
22
- @ssh.exec!('mv /opt/nginx/conf/nginx.conf /opt/nginx/conf/nginx.conf-orig')
23
- @ssh.exec!('wget https://raw.github.com/slava-vishnyakov/useful-stuff/master/nginx.conf -O /opt/nginx/conf/nginx.conf')
24
-
25
- what "Replacing passenger_ruby and passenger_root with actual Passenger data"
26
- orig_file = get_file_contents '/opt/nginx/conf/nginx.conf-orig'
27
- new_file = get_file_contents '/opt/nginx/conf/nginx.conf'
28
- new_file.sub! /passenger_ruby (.*?);/, orig_file.match(/passenger_ruby (.*?);/)[0]
29
- new_file.sub! /passenger_root (.*?);/, orig_file.match(/passenger_root (.*?);/)[0]
30
- put_file_contents '/opt/nginx/conf/nginx.conf', new_file
31
-
32
- what "Creating /opt/nginx/conf/rails-sites"
33
- @ssh.exec!('mkdir /opt/nginx/conf/rails-sites')
34
-
35
- what "Starting nginx"
36
- @ssh.exec!('sudo service nginx start')
37
- end
38
- end
39
-
40
- def create_site_config
41
- config = "
42
- server {
43
- listen #{@options[:site_port]};
44
- server_name #{@options[:site_host]};
45
- passenger_enabled on;
46
- root #{@options[:site_dir]}/current/public;
47
- passenger_user rails;
48
- passenger_max_requests 500;
49
- }
50
- "
51
- config_file = "/opt/nginx/conf/rails-sites/#{@options[:site_host]}-#{@options[:site_port]}.conf"
52
-
53
- if file_absent(config_file)
54
- put_file_contents(config_file, config)
55
- end
56
-
57
- if @ssh.exec!("sudo /opt/nginx/sbin/nginx -t") =~ /test is successful/
58
- @ssh.exec!("sudo service nginx reload")
59
- end
60
- end
61
-
62
- end
63
- end
@@ -1,43 +0,0 @@
1
- module Pointer
2
- module Postgres
3
- def install_postgres
4
- # install_postgres_database
5
- unless @ssh.exec! 'which psql'
6
- # official apt repo does not support 12.10 (quantal) yet :(
7
- puts @ssh.exec! 'sudo apt-get install -y libpq-dev'
8
- puts @ssh.exec! 'sudo apt-get install -y software-properties-common'
9
- puts @ssh.exec! 'sudo add-apt-repository ppa:pitti/postgresql'
10
- puts @ssh.exec! 'sudo apt-get update'
11
- puts @ssh.exec! 'sudo apt-get install -y postgresql-9.2'
12
- end
13
-
14
- # create_database
15
-
16
- if file_absent("#{@options[:site_dir]}/shared/config/database.yml")
17
- o = [('a'..'z'), ('A'..'Z'), ('0'..'9')].map { |i| i.to_a }.flatten
18
-
19
- # TODO: save these on server??
20
- password = (0...16).map { o[rand(o.length)] }.join
21
- username = 'user_' + host.gsub(/[^a-z0-9]/, '_')
22
- database = 'db_' + host.gsub(/[^a-z0-9]/, '_')
23
-
24
- # sudo sudo -u postgres - because we only have password-less sudo to root
25
- puts @ssh.exec!("sudo sudo -u postgres psql -c \"CREATE ROLE #{username} WITH CREATEDB LOGIN PASSWORD '#{password}'\"")
26
- puts @ssh.exec!("sudo sudo -u postgres psql -c \"CREATE DATABASE #{database} OWNER #{username}\"");
27
-
28
- # create database.yml
29
- "production:\n" +
30
- " adapter: postgresql\n" +
31
- " host: 127.0.0.1\n" +
32
- " encoding: utf8\n" +
33
- " database: #{database}\n" +
34
- " username: #{username}\n" +
35
- " password: #{password}\n" +
36
- ''
37
- else
38
- nil
39
- end
40
-
41
- end
42
- end
43
- end
@@ -1,48 +0,0 @@
1
- module Pointer
2
- module RailsUser
3
- def delete_rails_user
4
- puts @ssh.exec!("userdel rails -f -r")
5
- end
6
-
7
- def create_rails_user
8
- if @ssh.exec!("id rails") =~ /No such user/
9
- expect_empty @ssh.exec!("useradd rails -d /home/#{rails_user} -m -s /bin/bash")
10
- expect_empty @ssh.exec!("usermod -a -G sudo rails")
11
- what "User created: rails"
12
- else
13
- what "User exists: rails"
14
- end
15
- end
16
-
17
- def upload_public_key
18
- ssh_dir = "/home/#{rails_user}/.ssh"
19
- authorized_keys_file = ssh_dir + '/authorized_keys'
20
-
21
- what "Uploading private key"
22
- @ssh.exec!("mkdir #{ssh_dir}")
23
- ensure_file_contains(authorized_keys_file, IO.read(File.expand_path(public_key)))
24
- expect_empty @ssh.exec!("chown rails:rails #{ssh_dir}")
25
- expect_empty @ssh.exec!("chown rails:rails #{authorized_keys_file}")
26
- expect_empty @ssh.exec!("chmod 0700 #{ssh_dir}")
27
- expect_empty @ssh.exec!("chmod 0600 #{authorized_keys_file}")
28
- end
29
-
30
- def add_sudo
31
- sudo_string = "rails ALL = NOPASSWD:ALL"
32
- ensure_file_contains('/etc/sudoers', sudo_string)
33
- end
34
-
35
- def revoke_sudo
36
- puts "revoke_sudo is not implemented"
37
- end
38
-
39
- def print_deploy_key
40
- id_rsa = '/home/rails/.ssh/id_rsa'
41
- if file_absent(id_rsa)
42
- what "Generating ssh key"
43
- puts @ssh.exec!("ssh-keygen -q -t rsa -f #{id_rsa} -N ''")
44
- end
45
- end
46
-
47
- end
48
- end
@@ -1,25 +0,0 @@
1
- module Pointer
2
- module Rvm
3
- def install_rvm
4
- if file_absent("/home/#{rails_user}/.rvm/scripts/rvm")
5
- what "Update system"
6
- puts @ssh.exec!("sudo apt-get -qq -y update")
7
- what "Install build stuff"
8
- puts @ssh.exec!("sudo apt-get -qq -y install curl libcurl4-gnutls-dev git nodejs build-essential openssl " +
9
- " libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev " +
10
- " libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf " +
11
- " libc6-dev ncurses-dev automake libtool bison subversion pkg-config libgdbm-dev libffi-dev"
12
- )
13
- what "Actually install RVM (this takes some time)"
14
- puts @ssh.exec!("\\curl -L https://get.rvm.io | bash -s stable --ruby=#{ruby_version}")
15
-
16
- rvm!("rvm use #{ruby_version} --default")
17
- ensure_file_contains('/home/rails/.gemrc', 'gem: --no-ri --no-rdoc')
18
- end
19
- end
20
-
21
- def rvm!(command)
22
- @ssh.exec!(". /home/#{rails_user}/.rvm/scripts/rvm && (#{command})")
23
- end
24
- end
25
- end
@@ -1,84 +0,0 @@
1
- require 'tempfile'
2
- require 'net/ssh'
3
- require 'net/scp'
4
- require 'shellwords'
5
-
6
- module Pointer
7
- module SshHelpers
8
- def get_file_contents(file_name)
9
- @ssh.exec!("cat #{file_name.shellescape}")
10
- end
11
-
12
- def put_file_contents(file_name, string)
13
- file = Tempfile.new('ssh')
14
- file.write(string)
15
- file.rewind
16
- @ssh.scp.upload!(file.path, file_name)
17
- end
18
-
19
- def ensure_file_contains(file_name, string)
20
- contents = file_absent(file_name) ? '' : get_file_contents(file_name).to_s
21
- unless contents.include? string
22
- unless contents.end_with? "\n"
23
- contents += "\n"
24
- end
25
-
26
- contents += string
27
-
28
- put_file_contents(file_name, contents)
29
- end
30
- end
31
-
32
- def ensure_file_not_contains(file_name, string)
33
- contents = file_absent(file_name) ? '' : get_file_contents(file_name).to_s
34
-
35
- if contents and contents.include? string
36
- contents.gsub!(string, '')
37
- put_file_contents(file_name, contents)
38
- end
39
- end
40
-
41
- def file_absent(file_name)
42
- @ssh.exec!("ls #{file_name.shellescape}") =~ /No such file or directory/
43
- end
44
-
45
- def file_exists(file_name)
46
- not file_absent(file_name)
47
- end
48
-
49
- def expect_empty(string)
50
- if string
51
- puts string
52
- exit
53
- end
54
- end
55
-
56
- def with_ssh
57
- Net::SSH.start(host, rails_user, port: port, :keys => [private_key], :paranoid => false) do |ssh|
58
- @ssh = ssh
59
- yield
60
- @ssh = 'Connection closed'
61
- end
62
- end
63
-
64
- def with_root_ssh
65
- Net::SSH.start(host, user, port: port, :password => password, :paranoid => false) do |ssh|
66
- @ssh = ssh
67
- yield
68
- @ssh = 'Connection closed'
69
- end
70
- end
71
-
72
- def test_connection
73
- connection_test = `ssh -o StrictHostKeyChecking=no #{rails_user}@#{host} -p #{port} -i #{private_key} "echo OK"`
74
- if connection_test.strip == "OK"
75
- what "Connected via private key OK"
76
- else
77
- puts connection_test.on_red
78
- raise "I cannot connect via private key!"
79
- end
80
- end
81
-
82
-
83
- end
84
- end
@@ -1,59 +0,0 @@
1
- module Pointer
2
- module Variables
3
- def rails_user
4
- @options[:rails_user]
5
- end
6
-
7
- def private_key
8
- @options[:private_key]
9
- end
10
-
11
- def public_key
12
- @options[:public_key]
13
- end
14
-
15
- def password
16
- @options[:password]
17
- end
18
-
19
- def user
20
- @options[:ssh_user]
21
- end
22
-
23
- def host
24
- @options[:ssh_host]
25
- end
26
-
27
- def port
28
- @options[:ssh_port]
29
- end
30
-
31
- def ruby_version
32
- @options[:ruby_version] || "1.9.3"
33
- end
34
-
35
- def site_port
36
- @options[:site_port].to_i || 80
37
- end
38
-
39
- def nginx
40
- @options[:web_server] == :nginx
41
- end
42
-
43
- def bitbucket
44
- @options[:git_repo].include? '@bitbucket.org'
45
- end
46
-
47
- def mina
48
- @options[:deployer] == :mina
49
- end
50
-
51
- def deployer_application
52
- @options[:deployer_application]
53
- end
54
-
55
- def postgres
56
- @options[:database] == :postgres
57
- end
58
- end
59
- end