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

@ -6,7 +6,7 @@
**Merged pull requests:**
- Release 2.4.5 🦕 ([belomaxorka](https://github.com/belomaxorka))
- [CLI] TorrentPier installer ☕️ [\#1576](https://github.com/torrentpier/torrentpier/pull/1576) ([belomaxorka](https://github.com/belomaxorka))
- [CLI] TorrentPier installer ☕️ [\#1576](https://github.com/torrentpier/torrentpier/pull/1576), [\#1582](https://github.com/torrentpier/torrentpier/pull/1582) ([belomaxorka](https://github.com/belomaxorka))
- Added some new HTML meta-tags [\#1562](https://github.com/torrentpier/torrentpier/pull/1562) ([belomaxorka](https://github.com/belomaxorka))
- Added showing releaser stats in profile [\#1568](https://github.com/torrentpier/torrentpier/pull/1568) ([belomaxorka](https://github.com/belomaxorka))
- Fixed `md5()` deprecated in PHP 8.4 [\#1561](https://github.com/torrentpier/torrentpier/pull/1561) ([belomaxorka](https://github.com/belomaxorka))

View file

@ -73,7 +73,7 @@ For installation, you need to follow a few simple steps.
1. Install [Composer](https://getcomposer.org/)
2. Run `composer create-project torrentpier/torrentpier`
3. After run `composer install` on the project directory
4. Create database and import dump located at **install/sql/mysql.sql**
4. Create database and import dump located at `install/sql/mysql.sql`
5. Edit database configuration settings in the environment (`.env.example`, after rename to `.env`)
6. Voila! ✨
@ -81,13 +81,13 @@ For installation, you need to follow a few simple steps.
1. Edit domain name and domain port in the configuration file or a local copy (`$reserved_name` and `$reserved_port`)
2. Edit this files:
1. **favicon.png** (change on your own)
2. **robots.txt** (change the addresses in lines `Host` and `Sitemap` on your own)
3. **opensearch_desc.xml** (change the description and address on your own)
4. **opensearch_desc_bt.xml** (change the description and address on your own)
1. `favicon.png` (change on your own)
2. `robots.txt` (change the addresses in lines `Host` and `Sitemap` on your own)
3. `opensearch_desc.xml` (change the description and address on your own)
4. `opensearch_desc_bt.xml` (change the description and address on your own)
3. Log in to the forum with **admin/admin** login/password and finish setting up via admin panel
## 🔑 Access rights on folders and files
### 🔑 Access rights on folders and files (For manual installation only!)
You must provide write permissions to the specified folders:
* `data/avatars`
@ -108,8 +108,8 @@ If you discover a security vulnerability within TorrentPier, please follow our [
## 📌 Our recommendations
* *The recommended way to run cron.php.* - For significant tracker speed increase may be required to replace built-in cron.php by operating system daemon.
* *Local configuration copy.* - You can override the settings using local configuration file **library/config.local.php**.
* *The recommended way to run `cron.php`.* - For significant tracker speed increase may be required to replace built-in cron.php by operating system daemon.
* *Local configuration copy.* - You can override the settings using local configuration file `library/config.local.php`.
## 💚 Contributing / Contributors

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)) {