diff --git a/README.md b/README.md index d521d92..9e7c095 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ and manage customization through messages and buttons on Telegram. [![Total Downloads](https://img.shields.io/packagist/dt/cslant/laravel-telegram-git-notifier.svg?style=flat-square)](https://packagist.org/packages/cslant/laravel-telegram-git-notifier) ![Test Status](https://img.shields.io/github/actions/workflow/status/cslant/laravel-telegram-git-notifier/setup_test.yml?label=tests&branch=main) ![Code Style Status](https://img.shields.io/github/actions/workflow/status/cslant/laravel-telegram-git-notifier/php-cs-fixer.yml?label=code%20style&branch=main) -[![StyleCI](https://styleci.io/repos/656960426/shield)](https://styleci.io/repos/656960426) +[![StyleCI](https://styleci.io/repos/683727144/shield)](https://styleci.io/repos/683727144) [![Quality Score](https://img.shields.io/scrutinizer/g/cslant/laravel-telegram-git-notifier.svg?style=flat-square)](https://scrutinizer-ci.com/g/cslant/laravel-telegram-git-notifier) [![Maintainability](https://api.codeclimate.com/v1/badges/7ccaccebe9cd58ff3df5/maintainability)](https://codeclimate.com/github/cslant/laravel-telegram-git-notifier/maintainability) @@ -36,3 +36,21 @@ Publication of configuration files: ```bash php artisan vendor:publish --provider="CSlant\LaravelTelegramGitNotifier\Providers\TelegramGitNotifierServiceProvider" --tag="config_jsons" ``` + +## Fixing Permissions (for Linux) + +If you are using Linux, you need to change the owner of the configuration files to the web server user and group (e.g. `www-data`). + +The configuration files will be used to store the bot's settings and other information, so you need to change the owner of the configuration files to the web server user and group. + +```bash +sudo php artisan config-json:change-owner www-data www-data +``` + +> Note: +> - `www-data` is the user and group of the web server, you can change it to your own user and group. +> - The first `www-data` is the user, and the second `www-data` is the group. (You can also use only the first `www-data` to represent both the user and the group) + +## 📖 Documentation + +...In construction... diff --git a/src/Commands/ChangeOwnerConfigJson.php b/src/Commands/ChangeOwnerConfigJson.php new file mode 100644 index 0000000..41a084c --- /dev/null +++ b/src/Commands/ChangeOwnerConfigJson.php @@ -0,0 +1,40 @@ +argument('user'); + $group = $this->argument('group') ?? $user; + + $jsonsPath = config('telegram-git-notifier.data_file.storage_folder'); + if (is_string($jsonsPath) && file_exists($jsonsPath)) { + exec("chown -R $user:$group $jsonsPath"); + } + } +} diff --git a/src/Providers/TelegramGitNotifierServiceProvider.php b/src/Providers/TelegramGitNotifierServiceProvider.php index 0f3528f..7ed2954 100644 --- a/src/Providers/TelegramGitNotifierServiceProvider.php +++ b/src/Providers/TelegramGitNotifierServiceProvider.php @@ -2,6 +2,7 @@ namespace CSlant\LaravelTelegramGitNotifier\Providers; +use CSlant\LaravelTelegramGitNotifier\Commands\ChangeOwnerConfigJson; use Illuminate\Support\ServiceProvider; class TelegramGitNotifierServiceProvider extends ServiceProvider @@ -25,23 +26,9 @@ public function boot(): void $this->loadTranslationsFrom(__DIR__.'/../../lang', 'tg-notifier'); - $configPath = __DIR__.'/../../config/telegram-git-notifier.php'; - $this->publishes([ - $configPath => config_path('telegram-git-notifier.php'), - ], 'config'); - - $this->publishes([ - __DIR__.'/../../resources/views' => config('telegram-git-notifier.defaults.paths.views'), - ], 'views'); - - $this->publishes([ - __DIR__.'/../../lang' => resource_path('lang/vendor/tg-notifier'), - ], 'lang'); + $this->registerCommands(); - // copy config jsons from core package and ensure permissions are correct - $this->publishes([ - __DIR__.'/../../../telegram-git-notifier/config/jsons' => config('telegram-git-notifier.data_file.storage_folder'), - ], 'config_jsons'); + $this->registerAssetPublishing(); } /** @@ -64,4 +51,37 @@ public function provides(): ?array { return ['telegram-git-notifier']; } + + /** + * @return void + */ + protected function registerCommands(): void + { + $this->commands([ + ChangeOwnerConfigJson::class, + ]); + } + + /** + * @return void + */ + protected function registerAssetPublishing(): void + { + $configPath = __DIR__.'/../../config/telegram-git-notifier.php'; + $this->publishes([ + $configPath => config_path('telegram-git-notifier.php'), + ], 'config'); + + $this->publishes([ + __DIR__.'/../../resources/views' => config('telegram-git-notifier.defaults.paths.views'), + ], 'views'); + + $this->publishes([ + __DIR__.'/../../lang' => resource_path('lang/vendor/tg-notifier'), + ], 'lang'); + + $this->publishes([ + __DIR__.'/../../../telegram-git-notifier/config/jsons' => config('telegram-git-notifier.data_file.storage_folder'), + ], 'config_jsons'); + } }