Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a command to update permission/owner for config files in Linux #37

Merged
merged 10 commits into from
Nov 24, 2023
10 changes: 7 additions & 3 deletions src/Commands/ChangeOwnerConfigJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class ChangeOwnerConfigJson extends Command
*
* @var string
*/
protected $signature = 'config-json:change-owner {--user= : user}';
protected $signature = 'config-json:change-owner
{user : The user to change owner}
{group? : The group to change owner}';

/**
* The console command description.
Expand All @@ -27,10 +29,12 @@ class ChangeOwnerConfigJson extends Command
*/
public function handle(): void
{
$user = $this->option('user');
$user = $this->argument('user');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pxthinh using the argument instead of the option in the command console.

$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:$user $jsonsPath");
exec("chown -R $user:$group $jsonsPath");
}
}
}