mirror of
https://github.com/silverstripe/silverstripe-installer
synced 2024-10-22 17:05:33 +02:00
Merged branches/2.3 into trunk
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/trunk@66396 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e6d311212b
commit
abad46e6cb
19
.htaccess
19
.htaccess
@ -0,0 +1,19 @@
|
||||
### SILVERSTRIPE START ###
|
||||
<IfModule mod_dir.c>
|
||||
DirectorySlash Off
|
||||
</IfModule>
|
||||
|
||||
<Files *.ss>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
Allow from 127.0.0.1
|
||||
</Files>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
|
||||
|
||||
RewriteCond %{REQUEST_URI} ^(.*)$
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
|
||||
### SILVERSTRIPE END ###
|
15
Makefile
15
Makefile
@ -5,17 +5,6 @@
|
||||
# Most users should simply visit the site root in your web browser.
|
||||
#
|
||||
|
||||
suffix=`basename \`dirname \\\`pwd\\\`\``
|
||||
|
||||
install: mysite/_config.php
|
||||
|
||||
mysite/_config.php:
|
||||
php install.php install SS_testdatabase_${suffix}
|
||||
|
||||
test: clean install
|
||||
test:
|
||||
php ./sapphire/cli-script.php dev/build
|
||||
$(MAKE) -C sapphire test
|
||||
|
||||
clean:
|
||||
if [ -f .htaccess ]; then rm .htaccess; fi
|
||||
touch .htaccess
|
||||
if [ -f mysite/_config.php ]; then rm mysite/_config.php; fi
|
||||
|
57
install.php
57
install.php
@ -20,6 +20,7 @@ foreach($envFiles as $envFile) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Load database config
|
||||
if(isset($_REQUEST['mysql'])) {
|
||||
$databaseConfig = $_REQUEST['mysql'];
|
||||
@ -44,7 +45,19 @@ if(isset($_REQUEST['admin'])) {
|
||||
);
|
||||
}
|
||||
|
||||
$alreadyInstalled = (file_exists('mysite/_config.php') || file_exists('tutorial/_config.php'));
|
||||
$alreadyInstalled = false;
|
||||
if(file_exists('mysite/_config.php')) {
|
||||
// Find the $database variable in the relevant config file without having to execute the config file
|
||||
if(preg_match("/\\\$database\s*=\s*[^\n\r]+[\n\r]/", file_get_contents("mysite/_config.php"), $parts)) {
|
||||
eval($parts[0]);
|
||||
if($database) $alreadyInstalled = true;
|
||||
// Assume that if $databaseConfig is defined in mysite/_config.php, then a non-environment-based installation has
|
||||
// already gone ahead
|
||||
} else if(preg_match("/\\\$databaseConfig\s*=\s*[^\n\r]+[\n\r]/", file_get_contents("mysite/_config.php"), $parts)) {
|
||||
$alreadyInstalled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(file_exists('sapphire/silverstripe_version')) {
|
||||
$sapphireVersionFile = file_get_contents('sapphire/silverstripe_version');
|
||||
@ -150,7 +163,7 @@ class InstallRequirements {
|
||||
$this->requireFile('cms', array("File permissions", "cms/ folder exists", "There's no cms folder."));
|
||||
$this->requireFile('jsparty', array("File permissions", "jsparty/ folder exists", "There's no jsparty folder."));
|
||||
$this->requireWriteable('.htaccess', array("File permissions", "Is the .htaccess file writeable?", null));
|
||||
$this->requireWriteable('mysite', array("File permissions", "Is the mysite/ folder writeable?", null));
|
||||
$this->requireWriteable('mysite/_config.php', array("File permissions", "Is the mysite/_config.php file writeable?", null));
|
||||
$this->requireWriteable('assets', array("File permissions", "Is the assets/ folder writeable?", null));
|
||||
|
||||
$this->requireTempFolder(array('File permissions', 'Is the temporary folder writeable?', null));
|
||||
@ -357,24 +370,40 @@ class InstallRequirements {
|
||||
|
||||
function requireWriteable($filename, $testDetails) {
|
||||
$this->testing($testDetails);
|
||||
$filename = $this->getBaseDir() . $filename;
|
||||
$filename = $this->getBaseDir() . str_replace("/", DIRECTORY_SEPARATOR,$filename);
|
||||
|
||||
if(function_exists('posix_getgroups')) {
|
||||
if(!is_writeable($filename)) {
|
||||
$user = posix_getpwuid(posix_geteuid());
|
||||
if(function_exists('posix_getgroups')) {
|
||||
$userID = posix_geteuid();
|
||||
$user = posix_getpwuid($userID);
|
||||
|
||||
$currentOwnerID = fileowner($filename);
|
||||
$currentOwner = posix_getpwuid($currentOwnerID);
|
||||
|
||||
$testDetails[2] .= "User '$user[name]' needs to be able to write to this file:\n$filename\n\nThe file is currently owned by '$currentOwner[name]'. ";
|
||||
|
||||
if($user['name'] == $currentOwner['name']) {
|
||||
$testDetails[2] .= "We recommend that you make the file writeable.";
|
||||
} else {
|
||||
|
||||
$groups = posix_getgroups();
|
||||
foreach($groups as $group) {
|
||||
$groupInfo = posix_getgrgid($group);
|
||||
$groupList[] = $groupInfo['name'];
|
||||
}
|
||||
$groupList = "'" . implode("', '", $groupList) . "'";
|
||||
|
||||
$testDetails[2] .= "User '$user[name]' needs to be able to write to this file:\n$filename";
|
||||
$this->error($testDetails);
|
||||
if(in_array($currentOwner['name'], $groupInfo['members'])) $groupList[] = $groupInfo['name'];
|
||||
}
|
||||
if($groupList) {
|
||||
$testDetails[2] .= " We recommend that you make the file group-writeable and change the group to one of these groups:\n - ". implode("\n - ", $groupList)
|
||||
. "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename";
|
||||
} else {
|
||||
$testDetails[2] .= "Unable to detect whether I can write to files. Please ensure $filename is writable.";
|
||||
$this->warning($testDetails);
|
||||
$testDetails[2] .= " There is no user-group that contains both the web-server user and the owner of this file. Change the ownership of the file, create a new group, or temporarily make the file writeable by everyone during the install process.";
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$testDetails[2] .= "The webserver user needs to be able to write to this file:\n$filename";
|
||||
}
|
||||
|
||||
$this->error($testDetails);
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,7 +556,7 @@ class InstallRequirements {
|
||||
function getBaseDir() {
|
||||
// Cache the value so that when the installer mucks with SCRIPT_FILENAME half way through, this method
|
||||
// still returns the correct value.
|
||||
if(!$this->baseDir) $this->baseDir = realpath(dirname($_SERVER['SCRIPT_FILENAME'])) . '/';
|
||||
if(!$this->baseDir) $this->baseDir = realpath(dirname($_SERVER['SCRIPT_FILENAME'])) . DIRECTORY_SEPARATOR;
|
||||
return $this->baseDir;
|
||||
}
|
||||
|
||||
|
15
mysite/_config.php
Normal file
15
mysite/_config.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
global $project;
|
||||
$project = 'mysite';
|
||||
|
||||
global $database;
|
||||
$database = "";
|
||||
|
||||
require_once("conf/ConfigureFromEnv.php");
|
||||
|
||||
// This line set's the current theme. More themes can be
|
||||
// downloaded from http://www.silverstripe.com/themes/
|
||||
SSViewer::set_theme('blackcandy');
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user