aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormmn <mmn@hethane.se>2017-12-17 17:25:21 +0000
committermmn <mmn@hethane.se>2017-12-17 17:25:21 +0000
commita1ea335140a984365b6b5c908689d14afa464a81 (patch)
treefe4e2bd84bc8fb0f644bd0f83be3eb3ad8e05132
parent69bb81556f21b5708ac76fef87ba9c0ec859097c (diff)
parent0b9a2fdf3ad19942e85a66b94d08501ce9c927dd (diff)
downloadgnu-social-a1ea335140a984365b6b5c908689d14afa464a81.tar
gnu-social-a1ea335140a984365b6b5c908689d14afa464a81.zip
Merge branch 'cli-install' into 'master'
Don't write the config file when --skip-config flag is given to the installer. See merge request gnu/gnu-social!155
-rw-r--r--lib/installer.php17
-rwxr-xr-xscripts/install_cli.php2
2 files changed, 12 insertions, 7 deletions
diff --git a/lib/installer.php b/lib/installer.php
index 346c706d61..5f44812b23 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -85,7 +85,7 @@ abstract class Installer
$pass = true;
$config = INSTALLDIR.'/config.php';
- if (file_exists($config)) {
+ if (!$this->skipConfig && file_exists($config)) {
if (!is_writable($config) || filesize($config) > 0) {
if (filesize($config) == 0) {
$this->warning('Config file "config.php" already exists and is empty, but is not writable.');
@@ -126,14 +126,16 @@ abstract class Installer
}
// @fixme this check seems to be insufficient with Windows ACLs
- if (!is_writable(INSTALLDIR)) {
+ if (!$this->skipConfig && !is_writable(INSTALLDIR)) {
$this->warning(sprintf('Cannot write config file to: <code>%s</code></p>', INSTALLDIR),
sprintf('On your server, try this command: <code>chmod a+w %s</code>', INSTALLDIR));
$pass = false;
}
// Check the subdirs used for file uploads
- $fileSubdirs = array('avatar', 'file');
+ // TODO get another flag for this --skipFileSubdirCreation
+ if (!$this->skipConfig) {
+ $fileSubdirs = array($this->avatarDir, $this->fileDir);
foreach ($fileSubdirs as $fileSubdir) {
$fileFullPath = INSTALLDIR."/$fileSubdir";
if (!file_exists($fileFullPath)) {
@@ -148,7 +150,7 @@ abstract class Installer
$pass = false;
}
}
-
+ }
return $pass;
}
@@ -515,6 +517,9 @@ abstract class Installer
*/
function registerInitialUser()
{
+ // initalize hostname from install arguments, so it can be used to find
+ // the /etc config file from the commandline installer
+ $server = $this->server;
require_once INSTALLDIR . '/lib/common.php';
$data = array('nickname' => $this->adminNick,
@@ -580,10 +585,10 @@ abstract class Installer
return false;
}
+ if (!$this->skipConfig) {
// Make sure we can write to the file twice
$oldUmask = umask(000);
- if (!$this->skipConfig) {
$this->updateStatus("Writing config file...");
$res = $this->writeConf();
@@ -616,12 +621,12 @@ abstract class Installer
$this->updateStatus("Can't write to config file.", true);
return false;
}
- }
// Restore original umask
umask($oldUmask);
// Set permissions back to something decent
chmod(INSTALLDIR.'/config.php', 0644);
+ }
$scheme = $this->ssl === 'always' ? 'https' : 'http';
$link = "{$scheme}://{$this->server}/{$this->path}";
diff --git a/scripts/install_cli.php b/scripts/install_cli.php
index 815418aaab..da5f0f4b0c 100755
--- a/scripts/install_cli.php
+++ b/scripts/install_cli.php
@@ -47,10 +47,10 @@ class CliInstaller extends Installer
*/
function main()
{
+ if ($this->prepare()) {
if (!$this->checkPrereqs()) {
return false;
}
- if ($this->prepare()) {
return $this->handle();
} else {
$this->showHelp();