sumodev_deploy 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,10 +32,87 @@ configuration.load do
32
32
  run "create_db #{db_name}"
33
33
  end
34
34
 
35
+ desc "Imports the database from the server into your local database"
36
+ task :get, :roles => :db do
37
+ # @todo Defv would be nice if this also worked on production server. I think we need some extra vars in the capfile for username, password and host. by default these can be the values used on the dev-server.
38
+ system %{mysqladmin create #{db_name}}
39
+ system %{ssh sites@dev.sumocoders.eu mysqldump --set-charset #{db_name} | mysql #{db_name}}
40
+ end
41
+
35
42
  desc "Get database info"
36
43
  task :info, :roles => :db do
37
44
  run "info_db #{db_name}"
38
45
  end
46
+
47
+ desc "Imports the database from your local server to the remote one"
48
+ task :put, :roles => :db do
49
+ # @todo Defv would be nice if this also worked on production server. I think we need some extra vars in the capfile for username, password and host. by default these can be the values used on the dev-server.
50
+ system %{ssh sites@dev.sumocoders.eu "mysqldump --set-charset #{$db_name} > #{current_path}/#{release_name}.sql" }
51
+ system %{mysqldump --set-charset #{db_name} | ssh sites@dev.sumocoders.eu mysql #{db_name}}
52
+ end
53
+ end
54
+
55
+ namespace :files do
56
+ def find_folder_in_parents(folder)
57
+ require 'pathname'
58
+
59
+ path = Pathname.pwd
60
+ begin
61
+ found = Pathname.glob(path + folder)
62
+ return found.first if found.any?
63
+
64
+ path = path.parent
65
+ end until path.root?
66
+ end
67
+
68
+ desc "Sync all remote files to your local install"
69
+ task :get, :roles => :app do
70
+ path = find_folder_in_parents('frontend/files')
71
+ if !path
72
+ raise "No frontend/files folder found in this or upper folders. Are you sure you're in a Fork project?"
73
+ else
74
+ system %{rsync -rltp #{user}@dev.sumocoders.eu:#{shared_path}/files/ #{path}}
75
+ end
76
+ end
77
+
78
+ desc "Sync your local files to the remote server"
79
+ task :put, :roles => :app do
80
+ # create a backup on the remote, store it under the release-folder, so it will be automagically removed
81
+ run %{cd #{shared_path} && tar -czf #{current_path}/backup_files.tgz files}
82
+
83
+ # check if folder exists
84
+ path = find_folder_in_parents('frontend/files')
85
+ if !path
86
+ raise "No frontend/files folder found in this or upper folders. Are you sure you're in a Fork project?"
87
+ else
88
+ system %{rsync -rltp #{path} #{user}@dev.sumocoders.eu:#{shared_path}/files}
89
+ end
90
+ end
91
+ end
92
+
93
+ namespace :redirect do
94
+ desc "Installs the redirect page for the site"
95
+ task :put, :roles => :app do
96
+ unless exists?(:production_url)
97
+ fetch(:production_url) do
98
+ Capistrano::CLI.ui.ask "What is the production url?"
99
+ end
100
+ end
101
+
102
+ run %{
103
+ mkdir -p #{shared_path}/redirect &&
104
+ wget --quiet -O #{shared_path}/redirect/index.php http://static.sumocoders.be/redirect/index.phps &&
105
+ wget --quiet -O #{shared_path}/redirect/.htaccess http://static.sumocoders.be/redirect/htaccess
106
+ }
107
+
108
+ # change the url
109
+ run "if [ -f #{shared_path}/redirect/index.php ]; then sed -i 's/<real-url>/#{production_url.gsub(/['"\\\x0]/,'\\\\\0')}/' #{shared_path}/redirect/index.php; fi"
110
+
111
+ run %{
112
+ rm -f #{current_path} &&
113
+ ln -s #{shared_path}/redirect #{current_path}
114
+ }
115
+ end
39
116
  end
40
117
 
41
118
  namespace :setup do
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "sumodev_deploy"
5
- s.version = "0.1"
5
+ s.version = "0.2"
6
6
 
7
7
  s.authors = ["Jan De Poorter"]
8
8
  s.date = "2012-04-18"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sumodev_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: