-
Notifications
You must be signed in to change notification settings - Fork 1
/
aws_install_windows_service.txt
60 lines (49 loc) · 3.31 KB
/
aws_install_windows_service.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<powershell>
New-EventLog -LogName Application -Source kasm_startup_script
Write-EventLog -LogName "Application" -Source "kasm_startup_script" -EventID 1000 -EntryType Information -Message "Startup script has started."
Function Install-Winfsp {{
Write-EventLog -LogName "Application" -Source "kasm_startup_script" -EventID 1000 -EntryType Information -Message "Installing Winsfp"
Invoke-WebRequest -Uri $winfsp_url -OutFile $Env:temp\$winfsp_msi
Write-Host "Installing WinFSP"
Start-Process -FilePath $Env:temp\$winfsp_msi -ArgumentList '/q' -WorkingDirectory "C:\Windows\Temp\" -Wait
Remove-Item $Env:temp\$winfsp_msi -Force
}}
$user_home = "$profile_dir\$username"
$ProgressPreference = 'SilentlyContinue'
$winfsp_url = "https://github.com/winfsp/winfsp/releases/download/v2.0/winfsp-2.0.23075.msi"
$winfsp_msi = "winfsp-2.0.23075.msi"
$rclone_url = "https://github.com/rclone/rclone/releases/download/v1.64.0/rclone-v1.64.0-windows-amd64.zip"
$rclone_zip = "rclone-v1.64.0-windows-amd64.zip"
$rclone_bin = "C:\Program Files\Kasm\bin\rclone.exe"
# Download and install the Kasm Service
Write-EventLog -LogName "Application" -Source "kasm_startup_script" -EventID 1000 -EntryType Information -Message "Downloading Windows Service"
Invoke-Webrequest -URI https://kasm-static-content.s3.amazonaws.com/kasm_windows_service_installer_x86_64_1.2.22550d18.exe -OutFile C:\Users\Public\Downloads\kasm_service_installer.exe
Write-EventLog -LogName "Application" -Source "kasm_startup_script" -EventID 1000 -EntryType Information -Message "Installing Windows Service"
C:\Users\Public\Downloads\kasm_service_installer.exe /S
# Optionally download and install rclone and Winfsp, required for Cloud Storage Mapping to work
Install-Winfsp
for ($i = 1; $i -le 20; $i++) {{
Start-Sleep -s 3
$service = Get-Service -Name W32Time -ErrorAction SilentlyContinue
if ($service.Length -gt 0 -And (Test-Path -Path "C:\Users\Public\Downloads\kasm_service_installer.exe" -PathType Leaf)) {{
# Register the Kasm Service with the deployment
Write-EventLog -LogName "Application" -Source "kasm_startup_script" -EventID 1000 -EntryType Information -Message "Registering the Windows Service with the Kasm deployment at {upstream_auth_address}"
net stop kasm
cd "C:\Program Files\Kasm"
.\agent.exe --register-host {upstream_auth_address} --register-port 443 --server-id {server_id} --register-token {checkin_jwt}
if ($LastExitCode -eq 0) {{
net start kasm
Start-Service -Name "Audiosrv"
Write-EventLog -LogName "Application" -Source "kasm_startup_script" -EventID 1000 -EntryType Information -Message "Successfully installed and registered agent"
Exit 0
}} else {{
Write-EventLog -LogName "Application" -Source "kasm_startup_script" -EventID 1000 -EntryType Error -Message "Registration of Agent failed: Check log output of kasm_service in EventViewer"
Exit 1
}}
}} else {{
Write-EventLog -LogName "Application" -Source "kasm_startup_script" -EventID 1000 -EntryType Information -Message "Service not found, trying again..."
}}
}}
Write-EventLog -LogName "Application" -Source "kasm_startup_script" -EventID 1000 -EntryType Error -Message "Timed out waiting for Kasm Windows Service to be registered."
Exit 1
</powershell>