File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ class ChangeOwnerConfigJson extends Command
1212 * @var string
1313 */
1414 protected $ signature = 'config-json:change-owner
15- {user : The user to change owner}
15+ {user? : The user to change owner}
1616 {group? : The group to change owner} ' ;
1717
1818 /**
@@ -29,12 +29,23 @@ class ChangeOwnerConfigJson extends Command
2929 */
3030 public function handle (): void
3131 {
32- $ user = $ this ->argument ('user ' );
32+ if (PHP_OS_FAMILY !== 'Linux ' ) {
33+ $ this ->error ('This command only works on Linux ' );
34+ return ;
35+ }
36+
37+ $ user = $ this ->argument ('user ' ) ?? '' ;
3338 $ group = $ this ->argument ('group ' ) ?? $ user ;
3439
40+ if (empty ($ user ) || empty ($ group )) {
41+ $ group = $ user = exec ('ps aux | egrep "(apache|httpd|nginx)" | grep -v "root" | head -n1 | cut -d\ -f1 ' );
42+ }
43+
3544 $ jsonsPath = config ('telegram-git-notifier.data_file.storage_folder ' );
3645 if (is_string ($ jsonsPath ) && file_exists ($ jsonsPath )) {
37- exec ("chown -R $ user: $ group $ jsonsPath " );
46+ shell_exec ("chown -R $ user: $ group $ jsonsPath " );
47+ } else {
48+ $ this ->error ('The path to the jsons folder is not valid ' );
3849 }
3950 }
4051}
You can’t perform that action at this time.
0 commit comments