mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
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 commitb83e0846f9
. * Revert "Update install.php" This reverts commita7486cc20c
. * Revert "Update install.php" This reverts commitaf91f8aeb1
. * 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 commitc3621c3b9a
. * Revert "Update README.md" This reverts commit8832ccdcc2
. * Revert "Update README.md" This reverts commit428cc99521
. * Revert "Update README.md" This reverts commit282fd2658a
. * Revert "Update README.md" This reverts commit0836eaa941
. * Revert "Update README.md" This reverts commit525d980c69
. * Revert "Update README.md" This reverts commitdbd80c5a60
. * Revert "Update README.md" This reverts commit07eccab3e1
. * Update README.md * Update README.md
This commit is contained in:
parent
9d4466a596
commit
8af8497e55
3 changed files with 54 additions and 14 deletions
50
install.php
50
install.php
|
@ -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)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue