diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-09-30 15:59:41 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-09-30 15:59:41 -0300 |
commit | a29cc4859096edbf300ad648a08f9187834a063e (patch) | |
tree | 3e804559940e523dcf1cf31f913b10461ef2cdaa /templates | |
parent | 1ced786ff499f44a610924ceb209f6991bbffa14 (diff) | |
download | puppet-drupal-a29cc4859096edbf300ad648a08f9187834a063e.tar.gz puppet-drupal-a29cc4859096edbf300ad648a08f9187834a063e.tar.bz2 |
Support for drush site-install at drupal install
Diffstat (limited to 'templates')
-rw-r--r-- | templates/drupal.sh.erb | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/templates/drupal.sh.erb b/templates/drupal.sh.erb index bb65c5c..826059c 100644 --- a/templates/drupal.sh.erb +++ b/templates/drupal.sh.erb @@ -7,6 +7,26 @@ SITES="<%= apache_sites_folder %>" BASE="<%= apache_www_folder %>" SERIES="5 6 7" +# Read a parameter from user +function drupal_user_input { + local input + param="$1" + default="$2" + shift 2 + + if echo $param | grep -q 'passwd'; then + read -reps "$* (defaults to $default): " input + else + read -rep "$* (defaults to $default): " input + fi + + if [ -z "$input" ]; then + export $param=$default + else + export $param=$input + fi +} + # Get drupal major version function drupal_get_major { echo $1 | sed -e 's/\(^.\).*/\1/' @@ -234,18 +254,19 @@ function drupal_install { echo "Creating $SITES/$site/drupal/ structure..." mkdir -p $SITES/$site/drupal/files + echo "Copying default configuration file..." + cp $BASE/drupal-$series/sites/default/default.settings.php $SITES/$site/drupal/settings.php + chmod 640 $SITES/$site/drupal/settings.php + # Set files folder permission if grep -qe "^$site:" /etc/passwd; then + chown root.$site $SITES/$site/drupal/settings.php chown $site.$site $SITES/$site/drupal/files else + chown root.www-data $SITES/$site/drupal/settings.php chown www-data.www-data $SITES/$site/drupal/files fi - echo "Copying default configuration file..." - cp $BASE/drupal-$series/sites/default/default.settings.php $SITES/$site/drupal/settings.php - chown root.root $SITES/$site/drupal/settings.php - chmod 640 $SITES/$site/drupal/settings.php - ( echo "Creating symlinks..." cd $BASE/drupal-$series/sites @@ -257,7 +278,42 @@ function drupal_install { done ) - echo "Done. Now please edit settings.php, change it's permission an run drush site-install" + # Installation parameters + drupal_user_input profile "Installation profile" "standard" + drupal_user_input locale "Installation language" "pt_BR" + drupal_user_input admin "Admin user" "$site" + drupal_user_input admin_email "Admin email" "$site@`facter domain`" + drupal_user_input name "Site name" "$site" + drupal_user_input dbname "Database name" "$site" + drupal_user_input dbuser "Database user" "$site" + drupal_user_input dbpasswd "Database passwd" "$site" + + echo "Configuring settings.php" + if [ "$series" == "7" ]; then + cat >> $SITES/$site/drupal/settings.php <<-EOF +\$databases['default']['default'] = array( +'driver' => 'mysql', +'database' => '$dbname', +'username' => '$dbuser', +'password' => '$dbpasswd', +'host' => 'localhost', +'prefix' => '', +); + EOF + elif [ "$series" == "6" ]; then + cat >> $SITES/$site/drupal/settings.php <<-EOF +\$db_url = 'mysql://$dbuser:$dbpasswd@localhost/$dbname'; + EOF + fi + + ( + echo "Installing drupal $series for $site using $profile profile..." + cd $BASE/drupal-$series/ + drush site-install $profile --site-name="$name" --site-email="email" --locale=$locale \ + --uri="$site" --sites-subdir="$site" --account-name="$admin" --account-email="$admin_email" + ) + + echo "Done. Please check your installation." } # Main procedure |