Create auto-install script

boombatower - November 5, 2008 - 17:19
Project:Drupal
Version:7.x-dev
Component:base system
Category:task
Priority:normal
Assigned:boombatower
Status:duplicate
Description

This was discussed before, but a clean solution was not found. What we need is a way to install Drupal while it is running using the standard web interface. Without hacking it by placing a detect for simpletest in the installer or the like, I think the only way to do it would be to make a copy of the code in a writeable folder like /sites/default/files (w/e site) and then run the installer out of that directory through the web.

I have the install script that is being used on t.d.o. It doesn't click the links of the first few pages in an attempt to be minimal and have to be changed the least. Part of that is due to the way the minimalist SimpleTest browser was designed. It doesn't work when clicking relative links and such since it assumes they are in the active site as the base url. Which they aren't, they are inside base_url/sites/default/files/something/install.php

<?php
 
// Install Drupal.
 
$d = new DrupalWebTestCase();

 
// Step: Select an installation profile.
  // Step: Choose language.
 
$d->drupalGet('install.php', array('query' => 'profile=default&locale=en'));

 
// Step: Database configuration.
 
$edit = array();
 
$edit['database'] = $db;
 
$edit['username'] = $user;
 
$edit['password'] = $pass;
 
$edit['db_prefix'] = '';
 
$d->drupalPost(NULL, $edit, t('Save and continue'));

 
// Step: Site configuration.
 
$edit = array();
 
$edit['site_name'] = 'checkout';
 
$edit['site_mail'] = 'admin@example.com';
 
$edit['account[name]'] = 'admin';
 
$edit['account[mail]'] = 'admin@example.com';
 
$edit['account[pass][pass1]'] = $pass = $d->randomName(12);
 
$edit['account[pass][pass2]'] = $pass;
 
$edit['clean_url'] = 0;
 
$edit['update_status_module[1]'] = FALSE;
 
$d->drupalPost(NULL, $edit, t('Save and continue'));
?>

It should be able to just install itself in a prefixed directory like SimpleTest normally does, but it needs to remove the copied code afterwards so that it always copies the latest version of itself.

#1

boombatower - November 5, 2008 - 21:48

If this can be done then I can modify t.d.o to use it and it can be maintained like a test. Meaning changes to the installer won't hose t.d.o.

I already had to update the SimpleTest browser with the meta refresh patch which allows SimpleTest to run batch API pages.

#2

cyberswat - November 5, 2008 - 17:27

subscribing

#3

boombatower - November 6, 2008 - 23:53

One thought, should we make this a test or more of an automatic installation script and put it with the other scripts?

#4

boombatower - December 11, 2008 - 07:42

This could be made a test if we required a vhost setup with apache...or put some code atop index.php, update.php, and install.php that would switch the HTTP_HOST value when given specified parameters (although that could be dangerous).

#5

boombatower - December 11, 2008 - 07:42
Assigned to:Anonymous» boombatower

Forgot to set status: I have started (hour ago).

#6

boombatower - December 11, 2008 - 09:14
Component:simpletest.module» base system

Going the route of auto-install script which is much more feasible (for numerous technical reasons) and possibly more useful.

Initial pass...doesn't work at all. (got side tracked with: #345632: SimpleTest: correct assertTitle logic)

Currently it does on:

<?php
require_once drupal_get_path('module', 'simpletest') . '/drupal_web_test_case.php';
?>

drupal_get_path() apparently returns ''.

Might be due to this when bootstrapping:

PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /home/jimmy/software/php/drupal-7/scripts/auto-install.php:85) in /home/jimmy/software/php/drupal-7/includes/bootstrap.inc on line 1124
PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /home/jimmy/software/php/drupal-7/scripts/auto-install.php:85) in /home/jimmy/software/php/drupal-7/includes/bootstrap.inc on line 1124
PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/jimmy/software/php/drupal-7/scripts/auto-install.php:85) in /home/jimmy/software/php/drupal-7/includes/bootstrap.inc on line 717
PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/jimmy/software/php/drupal-7/scripts/auto-install.php:85) in /home/jimmy/software/php/drupal-7/includes/bootstrap.inc on line 718
PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/jimmy/software/php/drupal-7/scripts/auto-install.php:85) in /home/jimmy/software/php/drupal-7/includes/bootstrap.inc on line 719
PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/jimmy/software/php/drupal-7/scripts/auto-install.php:85) in /home/jimmy/software/php/drupal-7/includes/bootstrap.inc on line 720
PHP Notice:  Undefined index:  garland in /home/jimmy/software/php/drupal-7/includes/theme.inc on line 72
PHP Notice:  Trying to get property of non-object in /home/jimmy/software/php/drupal-7/includes/theme.inc on line 105
PHP Notice:  Trying to get property of non-object in /home/jimmy/software/php/drupal-7/includes/theme.inc on line 237

Thoughts?

AttachmentSizeStatusTest resultOperations
auto-install.php_.patch4.44 KBIgnoredNoneNone

#7

boombatower - December 11, 2008 - 09:08
Title:Find a way to put a test for the installer in SimpleTest» Create auto-install script

#8

boombatower - December 11, 2008 - 09:20

Just needed:

<?php
chdir
(DRUPAL_ROOT);
?>

#9

boombatower - December 11, 2008 - 09:31
Status:active» postponed

Updated script. This will require a bit of tweaking since DrupalWebTestCase now uses protected modifiers.

Postponing until: #340283: Abstract SimpleTest browser in to its own object

AttachmentSizeStatusTest resultOperations
auto-install.php_.patch4.7 KBIgnoredNoneNone

#10

adrian - January 15, 2009 - 16:07

we have an install script for Aegir.

It creates a drush command called 'provision install', and creates a mysql database and virtual host entry of the site for you.

we will also be plugging into unit testing in the future.

#11

boombatower - January 15, 2009 - 16:38

Core needs one in order for testing.drupal.org to function properly all the time.

#12

Josh Waihi - March 13, 2009 - 23:37

have you thought about simpletest implementing install tests. Then these tests could be called to install drupal. This would also take a step out of the PIFR process and merge it into the runningof the tests.

#13

boombatower - March 14, 2009 - 19:24

We ran into a number of problems with that. One being SimpleTest would need to have virtual hosts setup or something in order to allow it to run the installer...since the current code base it is running on is already installed....it is also A LOT more useful as a script.

This is extremely easy to do once someone (or me when I get time) finishes the abstract browser patch which is also useful in its own right. Making a test has a number of technical issues as webchick and I discussed in IRC a long time ago...and is not as useful of a solution.

#14

Dave Reid - March 14, 2009 - 19:52

I have a few patches that change the installer that are doomed to stay CNW until this lands. :)

#15

boombatower - July 28, 2009 - 19:01
Status:postponed» duplicate

Seems to be available with: #524728: Refactor install.php to allow Drupal to be installed from the command line

 
 

Drupal is a registered trademark of Dries Buytaert.