Programatically execute Drupal 6 install profile on fresh database without install.php

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
matt@antinomia's picture

I'm trying to update Druplet.module for Drupal 6. It's a simple module that creates new Drupal sites based on install profiles using multisite. It creates a new site directory, settings.php file, and database, and then executes the chosen install profile on the site, saving the user from having to step through the installer process.

In Drupal 5 it was fairly simple to do this:

<?php

 
// where $db_url['newsite'] is the SQL url from settings.php
 
db_set_active('newsite');

 
// include install functions
 
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/install.inc';

 
// Verify existence of all required modules.
 
$profile = 'default';
 
$modules = drupal_verify_profile($profile, NULL);

 
// Perform actual installation defined in the profile.
 
drupal_install_profile($profile, $modules);
 
variable_set('install_profile', $profile);
 
drupal_maintenance_theme();

 
// Show profile finalization info.
 
$function = $profile .'_profile_final';
  if (
function_exists($function)) {
   
// More steps required
   
$final = $function();
  }

 
// return db control to primary site
 
db_set_active('default');

 
// forward user to new site
 
drupal_goto('http://newsite.example.com');

?>

At the moment, I'm not able to figure out a clean way to do this in Drupal 6 without hacking apart install.php and install.inc. Has anybody had success with this?

Comments

two thoughts

greggles's picture

You might have more luck going for drupal_execute based techniques, though the installer is in a crazy time where normal Drupal things don't work so maybe that won't suffice.

There's also drush which might have good ideas but, again, it may rely too heavily on a normal Drupal environment where things like the DB exist.

Adrian Roussow (from RainCityStudios) is apparently doing lots of work with InstallProfiles but I don't see him in this group. It's probably worth pingning him directly.

--
Open Prediction Markets | Drupal Dashboard

Drush plus provision module

Boris Mann's picture

All the drush tools we built that are meant to work with Hostmaster are split off into their own backend. See provision project for that. As you can see on that project page, you can do this:

<?php
./drush.php provision install somesite.com
?>

P.S. I also just made Adrian part of this group :P

Drush

matt@antinomia's picture

Thanks guys... I'll look into Drush for this.

--
Matt Koglin, Antinomia Solutions

DAST

allisterbeharry's picture

You could use DAST - this is what it was designed for - http://drupal.org/project/DAST

I ended up just taking the

matt@antinomia's picture

I ended up just taking the essentials from install.php:

<?php
 
// where $db_url['newsite'] is the SQL url from settings.php
 
db_set_active('newsite');

 
// require the necessary files
 
require_once($_SERVER['DOCUMENT_ROOT'] . '/includes/install.inc');

 
$profile = 'default';
  require_once
"./profiles/$profile/$profile.profile";

 
// Verify existence of all required modules.
 
$modules = drupal_verify_profile($profile, NULL);

 
// install system.module
 
drupal_install_system();
 
$modules = array_diff($modules, array('system'));

 
// install other modules
 
$files = module_rebuild_cache();
 
$operations = array();
  foreach (
$modules as $module) {
   
_drupal_install_module($module);
   
module_enable(array($module));
  }
   
 
// Rebuild menu to get content type links registered by the profile,
  // and possibly any other menu items created through the tasks.
 
menu_rebuild();

 
// Register actions declared by any modules.
 
actions_synchronize();

 
// Randomize query-strings on css/js files, to hide the fact that
  // this is a new install, not upgraded yet.
 
_drupal_flush_css_js();
   
 
// Show profile finalization info.
 
$function = $profile .'_profile_final';
  if (
function_exists($function)) {
   
// More steps required
   
$site = $function($site);
  }

 
// return db control to primary site
 
db_set_active('default');

 
// forward user to new site
 
drupal_goto('http://newsite.example.com');
?>

Hope it's of use to somebody...

Oh, and thanks to Adrian for the guidance...

--
Matt Koglin, Antinomia Solutions

I have Tried This code but not working in D6

Kuldip Gohil's picture

Hello Experts...

I have tried this code but not working for drupal 6!!!

i have also made change in the code like

$function = $profile .'_profile_final'; _profile_final hook() not in D6 so i have tried using _task hook but its not working..,

Finally i want function like drupal_install_profile() which is in drupal 5.

Please Help Me on This....

Thanks,

Kuldip Gohil

Distributions

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week