Some improvements for CLI installer (#1582)

* Some improvements for CLI installer

* Update install.php

* Update install.php

* Update install.php

* Update install.php

* Revert "Update install.php"

This reverts commit b83e0846f9.

* Revert "Update install.php"

This reverts commit a7486cc20c.

* Revert "Update install.php"

This reverts commit af91f8aeb1.

* Update install.php

* Update install.php

* Update install.php

* Update CHANGELOG.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Revert "Update README.md"

This reverts commit c3621c3b9a.

* Revert "Update README.md"

This reverts commit 8832ccdcc2.

* Revert "Update README.md"

This reverts commit 428cc99521.

* Revert "Update README.md"

This reverts commit 282fd2658a.

* Revert "Update README.md"

This reverts commit 0836eaa941.

* Revert "Update README.md"

This reverts commit 525d980c69.

* Revert "Update README.md"

This reverts commit dbd80c5a60.

* Revert "Update README.md"

This reverts commit 07eccab3e1.

* Update README.md

* Update README.md
This commit is contained in:
Roman Kelesidis 2024-08-08 01:07:16 +07:00 committed by GitHub
commit 8af8497e55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 54 additions and 14 deletions

View file

@ -40,7 +40,7 @@ function out(string $str, string $type = ''): void
'warning' => "\033[33m$str \033[0m\n",
'info' => "\033[36m$str \033[0m\n",
'debug' => "\033[90m$str \033[0m\n",
default => $str,
default => "$str\n",
};
}
@ -90,8 +90,48 @@ function runProcess(string $cmd, string $input = null): void
proc_close($process);
}
/**
* Setting permissions recursively
*
* @param string $dir
* @param int $dirPermissions
* @param int $filePermissions
* @return void
*/
function chmod_r(string $dir, int $dirPermissions, int $filePermissions): void
{
$dp = opendir($dir);
while ($file = readdir($dp)) {
if (($file == '.') || ($file == '..')) {
continue;
}
$fullPath = realpath($dir . '/' . $file);
if (is_dir($fullPath)) {
out("- Directory: $fullPath");
chmod($fullPath, $dirPermissions);
chmod_r($fullPath, $dirPermissions, $filePermissions);
} elseif (is_file($fullPath)) {
out("- File: $fullPath");
chmod($fullPath, $filePermissions);
} else {
out("- Cannot find target path: $fullPath", 'error');
return;
}
}
closedir($dp);
}
// Welcoming message
out("- TorrentPier Installer\n", 'info');
out("--- TorrentPier Installer ---\n", 'info');
// Setting permissions
out('- Setting permissions for folders...', 'info');
chmod_r(ROOT . 'data', 0755, 0644);
chmod_r(ROOT . 'internal_data', 0755, 0644);
chmod_r(ROOT . 'sitemap', 0755, 0644);
out("- Permissions successfully applied!\n", 'success');
// Check composer installation
if (!is_file(ROOT . 'vendor/autoload.php')) {
@ -145,7 +185,7 @@ $DB_USERNAME = '';
$DB_PASSWORD = '';
if (is_file(ROOT . '.env')) {
out("--- Configuring TorrentPier ---\n", 'info');
out("--- Configuring TorrentPier ---", 'info');
$envContent = file_get_contents(ROOT . '.env');
if ($envContent === false) {
@ -166,8 +206,8 @@ if (is_file(ROOT . '.env')) {
$$key = $value;
}
out("Current value of $key: $value", 'debug');
out("Enter a new value for $key (or leave empty to not change): ");
out("\nCurrent value of $key: $value", 'debug');
echo "Enter a new value for $key (or leave empty to not change): ";
$newValue = readline();
if (!empty($newValue)) {