Skip to content

Instantly share code, notes, and snippets.

@pixxelboy
Created July 19, 2012 20:50
Show Gist options
  • Save pixxelboy/3146725 to your computer and use it in GitHub Desktop.
Save pixxelboy/3146725 to your computer and use it in GitHub Desktop.
Wordpress by Capistrano configuration for DB
/*
*
* Not much really, but hope it can help someday
* The goal is to edit the wp-config-sample.php, make it the required wp-config.php
* And asking the user to set login password for the target #{stage} DB settings.
* Cleaner than hardcoding anything in Capistrano files.
*
* This snippet is meant to work with the french version of the wp-config-sample.php file, and that makes it reallllly perfectible. Proposals praised !
*
*/
desc "Rather than a static config file hardcode, let's try sometgin else !"
set(:db_login, Capistrano::CLI.ui.ask("DB user: "))
set(:db_pass, Capistrano::CLI.ui.ask("DB password: "))
# First, based on the wp-config-sample.php, we create an original wp-config file.
run "cp #{latest_release}/wp-config-sample.php #{latest_release}/wp-config.php && rm #{latest_release}/wp-config-sample.php"
run "sed -i 's/votre_utilisateur_de_bdd/#{db_login}/1' #{latest_release}/wp-config.php"
run "sed -i 's/votre_mdp_de_bdd/#{db_pass}/1' #{latest_release}/wp-config.php"
run "sed -i 's/votre_nom_de_bdd/#{db_name}/1' #{latest_release}/wp-config.php"
run "sed -i 's/localhost/#{db_host}/1' #{latest_release}/wp-config.php"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment