【203】追加启动 minio
This commit is contained in:
parent
a9ec6c2a52
commit
f2323d6be3
@ -470,6 +470,88 @@ End If
|
||||
|
||||
}
|
||||
|
||||
function Start-MinIO {
|
||||
|
||||
# 进入 minio 目录下
|
||||
Set-Location "$MAIN_PATH"
|
||||
Set-Location ".."
|
||||
$WORKSPACE_PATH = Get-Location
|
||||
Set-Location "io"
|
||||
|
||||
if($outputWriteHost) {
|
||||
Write-Host "Start Minio ..."
|
||||
}
|
||||
$logMessage = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - 准备启动 Minio..."
|
||||
Append-Utf8NoBomContent -FilePath $outputLogFile -Content $logMessage
|
||||
|
||||
# 停止现有的 minio 进程
|
||||
Get-Process -Name "minio" -ErrorAction SilentlyContinue | Stop-Process -Force
|
||||
|
||||
# 配置默认启动参数
|
||||
$MINIO_PATH = "minio.exe"
|
||||
if (-not (Test-Path $MINIO_PATH)) {
|
||||
if($outputWriteHost) {
|
||||
Write-Host "Error: Cannot find minio.exe executable file."
|
||||
}
|
||||
pause
|
||||
Go-Home
|
||||
}
|
||||
|
||||
# 配置用户名和密码(可以改为从参数传入)
|
||||
$MINIO_ROOT_USER = "minio_34KYwR" # 默认用户名
|
||||
$MINIO_ROOT_PASSWORD = "minio_FEaTQx" # 默认密码
|
||||
|
||||
if($outputWriteHost) {
|
||||
Write-Host "$MINIO_PATH"
|
||||
}
|
||||
$logMessage = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - Minio executable file: $MINIO_PATH"
|
||||
Append-Utf8NoBomContent -FilePath $outputLogFile -Content $logMessage
|
||||
|
||||
# Minio 配置参数
|
||||
$MINIO_DATA_DIR = "data" # 数据目录
|
||||
$MINIO_PORT = 9000 # API 端口
|
||||
$MINIO_CONSOLE_PORT = 9001 # 控制台端口
|
||||
|
||||
# 创建以管理员身份运行的 VBS脚本
|
||||
$vbsContent = @"
|
||||
Set UAC = CreateObject("Shell.Application")
|
||||
Set WshShell = CreateObject("WScript.Shell")
|
||||
|
||||
On Error Resume Next
|
||||
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||
Set tempFile = fso.OpenTextFile("%SystemRoot%\System32\config\systemprofile", 1)
|
||||
If Err.Number = 0 Then
|
||||
WshShell.Run "cmd /c set MINIO_ROOT_USER=$MINIO_ROOT_USER && set MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD && $MINIO_PATH server $MINIO_DATA_DIR --console-address :$MINIO_CONSOLE_PORT", 0, False
|
||||
Else
|
||||
UAC.ShellExecute "cmd", "/c set MINIO_ROOT_USER=$MINIO_ROOT_USER && set MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD && $MINIO_PATH server $MINIO_DATA_DIR --console-address :$MINIO_CONSOLE_PORT", "", "runas", 0
|
||||
End If
|
||||
"@
|
||||
|
||||
# 以 ANSI 写入文件 temp.vbs
|
||||
$vbsContent | Out-File -FilePath "$WORKSPACE_PATH\io\temp.vbs" -Encoding ASCII
|
||||
if($outputWriteHost) {
|
||||
Write-Host "Temporary startup script has been created."
|
||||
}
|
||||
|
||||
# 运行 vbs 脚本
|
||||
Start-Process "cscript.exe" -ArgumentList "//nologo temp.vbs"
|
||||
|
||||
# 等待1秒后删除临时文件
|
||||
Start-Sleep -Seconds 1
|
||||
Remove-Item "temp.vbs" -Force
|
||||
|
||||
# 输出访问信息
|
||||
if($outputWriteHost) {
|
||||
Write-Host "Minio:"
|
||||
Write-Host "WEB: http://localhost:$MINIO_CONSOLE_PORT"
|
||||
Write-Host "API: http://localhost:$MINIO_PORT"
|
||||
Write-Host "user: $MINIO_ROOT_USER"
|
||||
Write-Host "pass: $MINIO_ROOT_PASSWORD"
|
||||
}
|
||||
$logMessage = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - Minio started successfully! Console port: $MINIO-CONSOLE-PORT, API port: $MINIO-PORT, username: $MINIO-COOT_USER"
|
||||
Append-Utf8NoBomContent -FilePath $outputLogFile -Content $logMessage
|
||||
}
|
||||
|
||||
function Start-SpringBoot {
|
||||
|
||||
# 准备启动后台服务
|
||||
@ -520,6 +602,9 @@ Check-Web
|
||||
# 启动 Nginx 服务
|
||||
Start-Web
|
||||
|
||||
# 启动 MinIO 服务
|
||||
Start-MinIO
|
||||
|
||||
Start-Sleep -Seconds 1
|
||||
# 检查 SpringBoot 运行环境
|
||||
Check-SpringBoot
|
||||
|
@ -420,6 +420,89 @@ End If
|
||||
|
||||
}
|
||||
|
||||
|
||||
function Start-MinIO {
|
||||
|
||||
# 进入 minio 目录下
|
||||
Set-Location "$MAIN_PATH"
|
||||
Set-Location ".."
|
||||
$WORKSPACE_PATH = Get-Location
|
||||
Set-Location "io"
|
||||
|
||||
if($outputWriteHost) {
|
||||
Write-Host "Start Minio ..."
|
||||
}
|
||||
$logMessage = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - 准备启动 Minio..."
|
||||
Append-Utf8NoBomContent -FilePath $outputLogFile -Content $logMessage
|
||||
|
||||
# 停止现有的 minio 进程
|
||||
Get-Process -Name "minio" -ErrorAction SilentlyContinue | Stop-Process -Force
|
||||
|
||||
# 配置默认启动参数
|
||||
$MINIO_PATH = "minio.exe"
|
||||
if (-not (Test-Path $MINIO_PATH)) {
|
||||
if($outputWriteHost) {
|
||||
Write-Host "Error: Cannot find minio.exe executable file."
|
||||
}
|
||||
pause
|
||||
Go-Home
|
||||
}
|
||||
|
||||
# 配置用户名和密码(可以改为从参数传入)
|
||||
$MINIO_ROOT_USER = "minio_34KYwR" # 默认用户名
|
||||
$MINIO_ROOT_PASSWORD = "minio_FEaTQx" # 默认密码
|
||||
|
||||
if($outputWriteHost) {
|
||||
Write-Host "$MINIO_PATH"
|
||||
}
|
||||
$logMessage = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - Minio executable file: $MINIO_PATH"
|
||||
Append-Utf8NoBomContent -FilePath $outputLogFile -Content $logMessage
|
||||
|
||||
# Minio 配置参数
|
||||
$MINIO_DATA_DIR = "data" # 数据目录
|
||||
$MINIO_PORT = 9000 # API 端口
|
||||
$MINIO_CONSOLE_PORT = 9001 # 控制台端口
|
||||
|
||||
# 创建以管理员身份运行的 VBS脚本
|
||||
$vbsContent = @"
|
||||
Set UAC = CreateObject("Shell.Application")
|
||||
Set WshShell = CreateObject("WScript.Shell")
|
||||
|
||||
On Error Resume Next
|
||||
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||
Set tempFile = fso.OpenTextFile("%SystemRoot%\System32\config\systemprofile", 1)
|
||||
If Err.Number = 0 Then
|
||||
WshShell.Run "cmd /c set MINIO_ROOT_USER=$MINIO_ROOT_USER && set MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD && $MINIO_PATH server $MINIO_DATA_DIR --console-address :$MINIO_CONSOLE_PORT", 0, False
|
||||
Else
|
||||
UAC.ShellExecute "cmd", "/c set MINIO_ROOT_USER=$MINIO_ROOT_USER && set MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD && $MINIO_PATH server $MINIO_DATA_DIR --console-address :$MINIO_CONSOLE_PORT", "", "runas", 0
|
||||
End If
|
||||
"@
|
||||
|
||||
# 以 ANSI 写入文件 temp.vbs
|
||||
$vbsContent | Out-File -FilePath "$WORKSPACE_PATH\io\temp.vbs" -Encoding ASCII
|
||||
if($outputWriteHost) {
|
||||
Write-Host "Temporary startup script has been created."
|
||||
}
|
||||
|
||||
# 运行 vbs 脚本
|
||||
Start-Process "cscript.exe" -ArgumentList "//nologo temp.vbs"
|
||||
|
||||
# 等待1秒后删除临时文件
|
||||
Start-Sleep -Seconds 1
|
||||
Remove-Item "temp.vbs" -Force
|
||||
|
||||
# 输出访问信息
|
||||
if($outputWriteHost) {
|
||||
Write-Host "Minio:"
|
||||
Write-Host "WEB: http://localhost:$MINIO_CONSOLE_PORT"
|
||||
Write-Host "API: http://localhost:$MINIO_PORT"
|
||||
Write-Host "user: $MINIO_ROOT_USER"
|
||||
Write-Host "pass: $MINIO_ROOT_PASSWORD"
|
||||
}
|
||||
$logMessage = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - Minio started successfully! Console port: $MINIO-CONSOLE-PORT, API port: $MINIO-PORT, username: $MINIO-COOT_USER"
|
||||
Append-Utf8NoBomContent -FilePath $outputLogFile -Content $logMessage
|
||||
}
|
||||
|
||||
function Start-SpringBoot {
|
||||
|
||||
# 准备启动后台服务
|
||||
@ -478,6 +561,9 @@ Check-Web
|
||||
# 启动 Nginx 服务
|
||||
Start-Web
|
||||
|
||||
# 启动 MinIO 服务
|
||||
Start-MinIO
|
||||
|
||||
Start-Sleep -Seconds 1
|
||||
# 检查 SpringBoot 运行环境
|
||||
Check-SpringBoot
|
||||
|
Loading…
x
Reference in New Issue
Block a user