Skip to content

Commit 02a95cb

Browse files
committed
fix get script username
1 parent 971a4b7 commit 02a95cb

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

app/Console/Commands/Test.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ public function __construct()
102102
*/
103103
public function handle()
104104
{
105-
$this->info("haha");
105+
$whoami = executeCommand('whoami');
106+
$user = get_current_user();
107+
$uid = getmyuid();
108+
$uid2 = posix_getuid();
109+
$info = posix_getpwuid($uid2);
110+
dd($whoami, $user, $uid, $uid2, $info);
106111
}
107112

108113
}

app/Filament/Resources/System/PluginStoreResource.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,7 @@ public static function table(Table $table): Table
8585
->label(fn () => sprintf("进入目录: %s, 以 root 用户的身份依次执行以下命令进行安装: ", base_path()))
8686
->html(true)
8787
->formatStateUsing(function (PluginStore $record) {
88-
$user = executeCommand("whoami");
89-
$commands = [
90-
sprintf("sudo -u %s composer config repositories.%s %s", $user, $record->plugin_id, $record->remote_url),
91-
sprintf("sudo -u %s composer require %s:%s", $user, $record->package_name, $record->version),
92-
sprintf("sudo -u %s php artisan plugin install %s", $user, $record->package_name),
93-
];
94-
return implode("<br/>", $commands);
88+
return self::getPluginInstruction($record);
9589
})
9690
,
9791
]);
@@ -105,6 +99,18 @@ public static function table(Table $table): Table
10599
;
106100
}
107101

102+
private static function getPluginInstruction(PluginStore $record): string
103+
{
104+
$result = [];
105+
$result[] = "配置扩展地址";
106+
$result[] = sprintf("<code>composer config repositories.%s git %s</code>", $record->plugin_id, $record->remote_url);
107+
$result[] = "<br/>下载扩展. 这里展示的最新版本号, 如果要要安装其他版本自行替换(dev-master 代表开发中的版本)";
108+
$result[] = sprintf("<code>composer require %s:%s</code>", $record->package_name, $record->version);
109+
$result[] = "<br/>执行安装";
110+
$result[] = sprintf("<code>php artisan plugin install %s</code>", $record->package_name);
111+
return implode("<br/>", $result);
112+
}
113+
108114
public static function getRelations(): array
109115
{
110116
return [

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"ext-xml": "*",
3434
"ext-zend-opcache": "*",
3535
"ext-zip": "*",
36+
"ext-posix": "*",
3637
"calebporzio/sushi": "^2.5",
3738
"elasticsearch/elasticsearch": "^7.16",
3839
"filament/filament": "^3.2",

include/globalfunctions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ function getLogFile($append = '')
265265
$name .= "-$append";
266266
}
267267
if (isRunningInConsole()) {
268-
$name .= sprintf("-cli-%s-%s", get_current_user(), getmyuid());
268+
$scriptUserInfo = posix_getpwuid(posix_getuid());
269+
$name .= sprintf("-cli-%s", $scriptUserInfo['name']);
269270
}
270271
$logFile = sprintf('%s-%s%s', $name, date('Y-m-d'), $suffix);
271272
return $logFiles[$append] = $logFile;

nexus/Install/Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function runExtraQueries()
343343
$this->runMigrate("database/migrations/2025_01_08_133847_create_user_modify_logs_table.php");
344344
$this->runMigrate("database/migrations/2025_01_18_235747_drop_users_table_text_column.php");
345345
$this->runMigrate("database/migrations/2025_01_18_235757_drop_torrents_table_text_column.php");
346-
Artisan::call("upgrade:upgrade:migrate_torrents_table_text_column");
346+
Artisan::call("upgrade:migrate_torrents_table_text_column");
347347
Artisan::call("upgrade:migrate_users_table_comment_related_column");
348348
}
349349
}

0 commit comments

Comments
 (0)