mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
Some improvements for CLI installer
This commit is contained in:
parent
9d4466a596
commit
1023a96cd0
1 changed files with 40 additions and 0 deletions
40
install.php
40
install.php
|
@ -90,9 +90,49 @@ 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 = $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');
|
||||
|
||||
// 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')) {
|
||||
out('- Hmm, it seems there are no Composer dependencies', 'info');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue