diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index d2fb2132..fadcea11 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -102,7 +102,12 @@ class Test extends Command */ public function handle() { - $this->info("haha"); + $whoami = executeCommand('whoami'); + $user = get_current_user(); + $uid = getmyuid(); + $uid2 = posix_getuid(); + $info = posix_getpwuid($uid2); + dd($whoami, $user, $uid, $uid2, $info); } } diff --git a/app/Filament/Resources/System/PluginStoreResource.php b/app/Filament/Resources/System/PluginStoreResource.php index a3512288..92922271 100644 --- a/app/Filament/Resources/System/PluginStoreResource.php +++ b/app/Filament/Resources/System/PluginStoreResource.php @@ -85,13 +85,7 @@ class PluginStoreResource extends Resource ->label(fn () => sprintf("进入目录: %s, 以 root 用户的身份依次执行以下命令进行安装: ", base_path())) ->html(true) ->formatStateUsing(function (PluginStore $record) { - $user = executeCommand("whoami"); - $commands = [ - sprintf("sudo -u %s composer config repositories.%s %s", $user, $record->plugin_id, $record->remote_url), - sprintf("sudo -u %s composer require %s:%s", $user, $record->package_name, $record->version), - sprintf("sudo -u %s php artisan plugin install %s", $user, $record->package_name), - ]; - return implode("
", $commands); + return self::getPluginInstruction($record); }) , ]); @@ -105,6 +99,18 @@ class PluginStoreResource extends Resource ; } + private static function getPluginInstruction(PluginStore $record): string + { + $result = []; + $result[] = "配置扩展地址"; + $result[] = sprintf("composer config repositories.%s git %s", $record->plugin_id, $record->remote_url); + $result[] = "
下载扩展. 这里展示的最新版本号, 如果要要安装其他版本自行替换(dev-master 代表开发中的版本)"; + $result[] = sprintf("composer require %s:%s", $record->package_name, $record->version); + $result[] = "
执行安装"; + $result[] = sprintf("php artisan plugin install %s", $record->package_name); + return implode("
", $result); + } + public static function getRelations(): array { return [ diff --git a/composer.json b/composer.json index 4d5bb698..80f5ca5a 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ "ext-xml": "*", "ext-zend-opcache": "*", "ext-zip": "*", + "ext-posix": "*", "calebporzio/sushi": "^2.5", "elasticsearch/elasticsearch": "^7.16", "filament/filament": "^3.2", diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 0acf50b5..956f6690 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -265,7 +265,8 @@ function getLogFile($append = '') $name .= "-$append"; } if (isRunningInConsole()) { - $name .= sprintf("-cli-%s-%s", get_current_user(), getmyuid()); + $scriptUserInfo = posix_getpwuid(posix_getuid()); + $name .= sprintf("-cli-%s", $scriptUserInfo['name']); } $logFile = sprintf('%s-%s%s', $name, date('Y-m-d'), $suffix); return $logFiles[$append] = $logFile; diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php index 2d4f2989..3fb82762 100644 --- a/nexus/Install/Update.php +++ b/nexus/Install/Update.php @@ -343,7 +343,7 @@ class Update extends Install $this->runMigrate("database/migrations/2025_01_08_133847_create_user_modify_logs_table.php"); $this->runMigrate("database/migrations/2025_01_18_235747_drop_users_table_text_column.php"); $this->runMigrate("database/migrations/2025_01_18_235757_drop_torrents_table_text_column.php"); - Artisan::call("upgrade:upgrade:migrate_torrents_table_text_column"); + Artisan::call("upgrade:migrate_torrents_table_text_column"); Artisan::call("upgrade:migrate_users_table_comment_related_column"); } }