Sfoglia il codice sorgente

fix: 优化userdata

iaun 7 mesi fa
parent
commit
ea8209d8e7
1 ha cambiato i file con 14 aggiunte e 0 eliminazioni
  1. 14 0
      server/src/services/userdata.ts

+ 14 - 0
server/src/services/userdata.ts

@@ -38,12 +38,26 @@ export function generateWindowsPassword(length = 16): string {
  * Generate a base64-encoded EC2 UserData PowerShell script that:
  * 1. Sets the MachineGuid registry value
  * 2. Changes the Administrator password
+ * 3. Installs GlobalProtect if not already installed
+ * 4. Configures GlobalProtect portal and LastUrl registry settings
  */
 export function generateUserData(machineGuid: string, adminPassword: string): string {
   const script = [
     '<powershell>',
     `Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Cryptography" -Name "MachineGuid" -Value "${machineGuid}"`,
     `net user Administrator '${adminPassword}'`,
+    '',
+    '# Configure GlobalProtect portal registry settings',
+    'New-Item -Path "HKLM:\\SOFTWARE\\Palo Alto Networks\\GlobalProtect\\PanSetup" -Force | Out-Null',
+    'Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Palo Alto Networks\\GlobalProtect\\PanSetup" -Name "Portal" -Value "yidingyingecv.lab.gpcloudservice.com"',
+    '',
+    'New-Item -Path "HKLM:\\SOFTWARE\\Palo Alto Networks\\GlobalProtect\\Settings" -Force | Out-Null',
+    'Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Palo Alto Networks\\GlobalProtect\\Settings" -Name "LastUrl" -Value "yidingyingecv.lab.gpcloudservice.com"',
+    '',
+    '# Install GlobalProtect if not already installed',
+    'if (-not (Test-Path "C:\\Program Files\\Palo Alto Networks\\GlobalProtect\\PanGPS.exe")) {',
+    '    Start-Process msiexec.exe -ArgumentList \'/i "C:\\Users\\Administrator\\Downloads\\GlobalProtect64.msi" DEFAULTBROWSER=YES /quiet /norestart\' -Wait',
+    '}',
     '</powershell>',
     '<persist>true</persist>',
   ].join('\n');