metastrano 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/helpers.rb CHANGED
@@ -1,7 +0,0 @@
1
- def config_path
2
- "#{current_release}/config/"
3
- end
4
-
5
- def shared_config_path
6
- "#{shared_path}/config/"
7
- end
data/lib/metastrano.rb CHANGED
@@ -3,17 +3,48 @@ require 'capistrano/cli'
3
3
 
4
4
  Capistrano::Configuration.instance(:must_exist).load do
5
5
 
6
- # basic setup stuff
7
- set :config_files, 'database.yml' unless exists?(:config_files)
8
- set :environment, 'production' unless exists?(:environment)
9
- set :repo_path, '/home/git' unless exists?(:repo_path)
6
+ #----------------------------------------------------------------
7
+ # configuration & defaults
8
+ #----------------------------------------------------------------
9
+
10
+ set :config_files, 'database.yml'
11
+ set :shared_children, %w(system log pids config)
12
+ set :environment, 'production'
13
+ set :repo_path, '/home/git'
10
14
  set :ruby_path, '/opt/ruby-enterprise-1.8.7-2009.10/bin/'
11
- set :user, 'capistrano' unless exists?(:user)
15
+ set :user, 'capistrano'
12
16
 
13
17
  # version control
14
18
  set :scm, :git
15
19
  set :scm_username, :git
20
+
21
+ # wordpress defaualts
22
+ set :wordpress_version, '2.8.6'
23
+ set :wordpress_symlinks, ["wp-content/avatars","wp-content/uploads","wp-content/cache"]
24
+ set :wordpress_editable_dirs, ["wp-content/uploads"]
25
+
26
+ #----------------------------------------------------------------
27
+ # filters
28
+ #----------------------------------------------------------------
29
+
30
+ # after application setup
31
+ after "deploy:setup" do
32
+ db.mysql.setup if Capistrano::CLI.ui.agree("Do you want to create the database, user, and config/database.yml file?")
33
+ apache.create_vhost if Capistrano::CLI.ui.agree("Do you want to create the apache virtual host file?")
34
+ end
35
+
36
+ #----------------------------------------------------------------
37
+ # helper methods
38
+ #----------------------------------------------------------------
16
39
 
40
+ def metastrano_symlink(existing_path, symlinked_path)
41
+ sudo "ln -nfs #{existing_path} #{symlinked_path}"
42
+ end
43
+
44
+ def metastrano_chmod(file, ownership = '0777')
45
+ sudo "chmod #{ownership} -R #{file}"
46
+ end
47
+
17
48
  def metastrano_load_template_file(file_name)
18
49
  local_file = "config/metastrano/#{file_name}"
19
50
  file_path = File.exists?(local_file) ? local_file : MetaStrano.path + "/templates/#{file_name}"
@@ -28,8 +59,8 @@ Capistrano::Configuration.instance(:must_exist).load do
28
59
  def prepare_for_db_command
29
60
  set :db_name, "#{application}_#{environment}" unless exists?(:db_name)
30
61
  set(:db_admin_user) { Capistrano::CLI.ui.ask "Username with priviledged database access (to create db):" } unless exists?(:db_admin_user)
31
- set(:db_user) { Capistrano::CLI.ui.ask "Enter #{environment} database username:" } unless exists?(:db_user)
32
- set(:db_pass) { Capistrano::CLI.password_prompt "Enter #{environment} database password:" } unless exists?(:db_pass)
62
+ set(:db_user) { Capistrano::CLI.ui.ask "Enter database username:" } unless exists?(:db_user)
63
+ set(:db_pass) { Capistrano::CLI.password_prompt "Enter database password:" } unless exists?(:db_pass)
33
64
  end
34
65
  end
35
66
 
@@ -17,7 +17,7 @@ Capistrano::Configuration.instance(:must_exist).load do
17
17
  vhost = metastrano_load_erb_file('apache.conf.erb')
18
18
 
19
19
  # uploads the above vhost file onto the server
20
- put vhost.result, "#{shared_path}/config/#{application}.conf"
20
+ put vhost, "#{shared_path}/config/#{application}.conf"
21
21
 
22
22
  # removes any existing apache conf files
23
23
  sudo "rm -f /etc/httpd/conf.d/#{application}.conf"
@@ -26,6 +26,12 @@ Capistrano::Configuration.instance(:must_exist).load do
26
26
  # make a symbolic link back to the shared config directory
27
27
  sudo "ln -nfs /etc/httpd/conf.d/#{application}.conf #{shared_path}/config/#{application}.conf"
28
28
  end
29
+
30
+ desc "Chown files and folders for apache. This is used primarily for the wordpress uploads folders"
31
+ task :restart, :roles => :app, :except => { :no_release => true } do
32
+ apache.restart
33
+ end
34
+
29
35
  end
30
36
 
31
37
  end
data/lib/recipes/db.rb CHANGED
@@ -47,13 +47,13 @@ Capistrano::Configuration.instance(:must_exist).load do
47
47
  run "mkdir -p #{shared_path}/config"
48
48
  db_config = metastrano_load_erb_file('database.yml.erb')
49
49
  # uploads the database.yml config file
50
- put db_config.result, "#{shared_path}/config/database.yml"
50
+ put db_config, "#{shared_path}/config/database.yml"
51
51
  end
52
52
 
53
53
  desc "Updates the symlink for database.yml file to the just deployed release."
54
54
  task :symlink, :except => { :no_release => true } do
55
- run "rm -f #{release_path}/config/database.yml"
56
- run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
55
+ run "rm -f #{current_path}/config/database.yml"
56
+ run "ln -nfs #{shared_path}/config/database.yml #{current_path}/config/database.yml"
57
57
  end
58
58
 
59
59
  desc "Loads remote production data into development database. Uses your local database.yml file for development and production passwords"
@@ -0,0 +1,29 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ #----------------------------------------------------------------
4
+ # DelayedJob
5
+ # - Restart stops and starts because
6
+ # - I found the restart command to be buggy
7
+ #----------------------------------------------------------------
8
+
9
+ namespace :delayed_job do
10
+
11
+ desc "Restart the delayed_job process"
12
+ task :restart, :roles => :app do
13
+ stop
14
+ start
15
+ end
16
+
17
+ desc "Start the delayed_job process"
18
+ task :start, :roles => :app do
19
+ run "cd #{current_path}; #{sudo} RAILS_ENV=#{rails_env} script/delayed_job start"
20
+ end
21
+
22
+ desc "Stop the delayed_job process"
23
+ task :stop, :roles => :app do
24
+ run "cd #{current_path}; #{sudo} RAILS_ENV=#{rails_env} script/delayed_job stop"
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -13,7 +13,7 @@ Capistrano::Configuration.instance(:must_exist).load do
13
13
 
14
14
  desc "Update the crontab file if you are using the whenever GEM"
15
15
  task :update_crontab, :roles => :db do
16
- run "cd #{release_path} && #{sudo} whenever --update-crontab #{application}"
16
+ run "cd #{current_path} && #{sudo} whenever --update-crontab #{application}"
17
17
  end
18
18
 
19
19
  [:start, :stop].each do |t|
data/lib/recipes/setup.rb CHANGED
@@ -11,6 +11,7 @@ Capistrano::Configuration.instance(:must_exist).load do
11
11
  run_locally "cp #{MetaStrano.path}/templates/apache.conf.erb config/metastrano/apache.conf.erb"
12
12
  run_locally "cp #{MetaStrano.path}/templates/database.yml.erb config/metastrano/database.yml.erb"
13
13
  run_locally "cp #{MetaStrano.path}/templates/gitignore.erb config/metastrano/gitignore.erb"
14
+ run_locally "cp #{MetaStrano.path}/templates/wordpress.#{wordpress_version}.php.erb config/metastrano/wordpress.#{wordpress_version}.php.erb"
14
15
  end
15
16
  end
16
17
 
@@ -5,6 +5,13 @@ Capistrano::Configuration.instance(:must_exist).load do
5
5
  #----------------------------------------------------------------
6
6
 
7
7
  namespace :symlink do
8
+ desc "Creates shared directories and symlinks shared directories and files"
9
+ task :setup, :roles => :app do
10
+ create_shared_dirs
11
+ shared_directories
12
+ shared_config_files
13
+ end
14
+
8
15
  desc <<-DESC
9
16
  Create shared directories. Specify which directories are shared via:
10
17
  set :shared_dirs, %w(avatars videos)
@@ -0,0 +1,72 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ #----------------------------------------------------------------
4
+ # Wordpress
5
+ #
6
+ # create wordpress database and its user
7
+ # create the wp-config file
8
+ # symlink the wo-config file from its shared/config/wp-config file to current_path/blog/wp-config.php
9
+ # symlink any uploadable assets
10
+ #
11
+ #----------------------------------------------------------------
12
+
13
+ namespace :wordpress do
14
+ desc "Setup the database"
15
+ task :create_database do
16
+ set :db_name, "#{application}_wordpress"
17
+ prepare_for_db_command
18
+ db.mysql.create_db
19
+ end
20
+
21
+ desc "Generate the config file"
22
+ task :create_config_file do
23
+ prepare_for_db_command
24
+ set :db_name, "#{application}_wordpress"
25
+ config_file = metastrano_load_erb_file("wordpress.#{wordpress_version}.php.erb")
26
+
27
+ # uploads the above vhost file onto the server
28
+ put config_file, "#{shared_path}/config/wp-config.php"
29
+
30
+ # removes any existing wp-config files
31
+ sudo "rm -f #{current_path}/blog/wp-config.php"
32
+ end
33
+
34
+ desc "Symlink the files for 'avatars', 'uploads' and 'cache'. Override this by setting :wordpress_symlinks"
35
+ task :symlink_folders do
36
+ wordpress_symlinks.each do |path|
37
+ sudo "mkdir -p #{shared_path}/blog/#{path}"
38
+ sudo "rm -f #{current_path}/public/blog/#{path}"
39
+ metastrano_symlink("#{shared_path}/blog/#{path}", "#{current_path}/public/blog/#{path}")
40
+ end
41
+ end
42
+
43
+ desc "Symlink the wp-config file from shared_path/config/wp-config to current_path/public/blog/wp-config"
44
+ task :symlink_config_file do
45
+ sudo "rm -f #{current_path}/public/blog/wp-config.php"
46
+ metastrano_symlink("#{shared_path}/config/wp-config.php", "#{current_path}/public/blog/wp-config.php")
47
+ end
48
+
49
+ desc "Creates the database and its user, uploads the wp-config file, and symlinks the shared/config file with your current_path directory"
50
+ task :setup do
51
+ prepare_for_db_command
52
+ create_database
53
+ create_config_file
54
+ create_symlinks
55
+ make_folders_editable
56
+ end
57
+
58
+ desc "Symlinks the config files and image-uploads, avitar and cache folders"
59
+ task :create_symlinks do
60
+ symlink_config_file
61
+ symlink_folders
62
+ end
63
+
64
+ desc "Makes the necessary folders editable such as the wp-content/uploads directory"
65
+ task :make_folders_editable do
66
+ wordpress_editable_dirs.each do |path|
67
+ metastrano_chmod("#{shared_path}/blog/#{path}")
68
+ end
69
+ end
70
+ end
71
+
72
+ end
@@ -0,0 +1,76 @@
1
+ <?php
2
+ /**
3
+ * The base configurations of the WordPress.
4
+ *
5
+ * This file has the following configurations: MySQL settings, Table Prefix,
6
+ * Secret Keys, WordPress Language, and ABSPATH. You can find more information by
7
+ * visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
8
+ * wp-config.php} Codex page. You can get the MySQL settings from your web host.
9
+ *
10
+ * This file is used by the wp-config.php creation script during the
11
+ * installation. You don't have to use the web site, you can just copy this file
12
+ * to "wp-config.php" and fill in the values.
13
+ *
14
+ * @package WordPress
15
+ */
16
+
17
+ // ** MySQL settings - You can get this info from your web host ** //
18
+ /** The name of the database for WordPress */
19
+ define('DB_NAME', '<%= db_name %>');
20
+
21
+ /** MySQL database username */
22
+ define('DB_USER', '<%= db_user %>');
23
+
24
+ /** MySQL database password */
25
+ define('DB_PASSWORD', '<%= db_pass %>');
26
+
27
+ /** MySQL hostname */
28
+ define('DB_HOST', 'localhost');
29
+
30
+ /** Database Charset to use in creating database tables. */
31
+ define('DB_CHARSET', 'utf8');
32
+
33
+ /** The Database Collate type. Don't change this if in doubt. */
34
+ define('DB_COLLATE', '');
35
+
36
+ /**#@+
37
+ * Authentication Unique Keys.
38
+ *
39
+ * Change these to different unique phrases!
40
+ * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/ WordPress.org secret-key service}
41
+ * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
42
+ *
43
+ * @since 2.6.0
44
+ */
45
+ define('AUTH_KEY', 'put your unique phrase here');
46
+ define('SECURE_AUTH_KEY', 'put your unique phrase here');
47
+ define('LOGGED_IN_KEY', 'put your unique phrase here');
48
+ define('NONCE_KEY', 'put your unique phrase here');
49
+ /**#@-*/
50
+
51
+ /**
52
+ * WordPress Database Table prefix.
53
+ *
54
+ * You can have multiple installations in one database if you give each a unique
55
+ * prefix. Only numbers, letters, and underscores please!
56
+ */
57
+ $table_prefix = 'wp_';
58
+
59
+ /**
60
+ * WordPress Localized Language, defaults to English.
61
+ *
62
+ * Change this to localize WordPress. A corresponding MO file for the chosen
63
+ * language must be installed to wp-content/languages. For example, install
64
+ * de.mo to wp-content/languages and set WPLANG to 'de' to enable German
65
+ * language support.
66
+ */
67
+ define ('WPLANG', '');
68
+
69
+ /* That's all, stop editing! Happy blogging. */
70
+
71
+ /** WordPress absolute path to the Wordpress directory. */
72
+ if ( !defined('ABSPATH') )
73
+ define('ABSPATH', dirname(__FILE__) . '/');
74
+
75
+ /** Sets up WordPress vars and included files. */
76
+ require_once(ABSPATH . 'wp-settings.php');
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metastrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Paul Narowski
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-20 00:00:00 -05:00
12
+ date: 2010-02-16 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -61,14 +61,17 @@ files:
61
61
  - lib/metastrano.rb
62
62
  - lib/recipes/apache.rb
63
63
  - lib/recipes/db.rb
64
+ - lib/recipes/delayed_job.rb
64
65
  - lib/recipes/deploy.rb
65
66
  - lib/recipes/git.rb
66
67
  - lib/recipes/rake.rb
67
68
  - lib/recipes/setup.rb
68
69
  - lib/recipes/symlink.rb
70
+ - lib/recipes/wordpress.rb
69
71
  - lib/templates/apache.conf.erb
70
72
  - lib/templates/database.yml.erb
71
73
  - lib/templates/gitignore
74
+ - lib/templates/wordpress.2.8.6.php.erb
72
75
  - test/helper.rb
73
76
  - test/test_metastrano.rb
74
77
  has_rdoc: true