mirror of
https://github.com/fleetdm/fleet
synced 2026-05-02 02:47:30 +00:00
- Added Teams input configuration for winget package manager - Created Windows-specific Teams app manifest with install/uninstall scripts - Updated apps.json to include microsoft-teams/windows entry <!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves # # Checklist for submitter If some of the following don't apply, delete the relevant line. - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. - [ ] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [ ] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes ## Testing - [ ] Added/updated automated tests - [ ] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [ ] QA'd all new/changed functionality manually For unreleased bug fixes in a release candidate, one of: - [ ] Confirmed that the fix is not expected to adversely impact load test results - [ ] Alerted the release DRI if additional load testing is needed ## Database migrations - [ ] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [ ] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [ ] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). ## New Fleet configuration settings - [ ] Setting(s) is/are explicitly excluded from GitOps If you didn't check the box above, follow this checklist for GitOps-enabled settings: - [ ] Verified that the setting is exported via `fleetctl generate-gitops` - [ ] Verified the setting is documented in a separate PR to [the GitOps documentation](https://github.com/fleetdm/fleet/blob/main/docs/Configuration/yaml-files.md#L485) - [ ] Verified that the setting is cleared on the server if it is not supplied in a YAML file (or that it is documented as being optional) - [ ] Verified that any relevant UI is disabled when GitOps mode is enabled ## fleetd/orbit/Fleet Desktop - [ ] Verified compatibility with the latest released version of Fleet (see [Must rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/workflows/fleetd-development-and-release-strategy.md)) - [ ] If the change applies to only one platform, confirmed that `runtime.GOOS` is used as needed to isolate changes - [ ] Verified that fleetd runs on macOS, Linux and Windows - [ ] Verified auto-update works from the released version of component to the new version (see [tools/tuf/test](../tools/tuf/test/README.md))
130 lines
4.1 KiB
PowerShell
130 lines
4.1 KiB
PowerShell
$softwareName = "MSTeams-x64"
|
|
$msixPath = "${env:INSTALLER_PATH}"
|
|
$taskName = "fleet-install-$softwareName.msix"
|
|
$scriptPath = "$env:PUBLIC\install-$softwareName.ps1"
|
|
$exitCodeFile = "$env:PUBLIC\install-exitcode-$softwareName.txt"
|
|
|
|
$userScript = @"
|
|
`$msixPath = "$msixPath"
|
|
`$exitCodeFile = "$exitCodeFile"
|
|
`$exitCode = 0
|
|
|
|
try {
|
|
Write-Host "=== Teams Installation Start ==="
|
|
Write-Host "MSIX Path: `$msixPath"
|
|
|
|
# Provision for all future users
|
|
Write-Host "[1/3] Provisioning for all future users..."
|
|
Add-AppProvisionedPackage -Online -PackagePath `$msixPath -SkipLicense -ErrorAction Stop
|
|
Write-Host "[1/3] Provisioning complete"
|
|
|
|
# Also install for current user so osquery can detect it immediately
|
|
Write-Host "[2/3] Installing for current user..."
|
|
Add-AppxPackage -Path `$msixPath -ErrorAction Stop
|
|
Write-Host "[2/3] Installation complete"
|
|
|
|
# Poll for package registration (up to 30 seconds)
|
|
Write-Host "[3/3] Polling for registration (max 30s)..."
|
|
`$maxAttempts = 30
|
|
`$attempt = 0
|
|
`$installed = `$null
|
|
|
|
while (`$attempt -lt `$maxAttempts) {
|
|
`$installed = Get-AppxPackage -Name "MSTeams" -ErrorAction SilentlyContinue
|
|
if (`$installed) {
|
|
Write-Host "[3/3] Package registered after `$attempt seconds"
|
|
break
|
|
}
|
|
Start-Sleep -Seconds 1
|
|
`$attempt++
|
|
}
|
|
|
|
if (-not `$installed) {
|
|
Write-Host "[3/3] ERROR: Package not registered after `$attempt seconds"
|
|
`$exitCode = 1
|
|
} else {
|
|
Write-Host "=== Installation Successful ==="
|
|
Write-Host "Package: `$(`$installed.PackageFullName)"
|
|
Write-Host "Version: `$(`$installed.Version)"
|
|
}
|
|
} catch {
|
|
Write-Host "=== Installation Failed ==="
|
|
Write-Host "Error: `$(`$_.Exception.Message)"
|
|
`$exitCode = 1
|
|
} finally {
|
|
Write-Host "Exit Code: `$exitCode"
|
|
Set-Content -Path `$exitCodeFile -Value `$exitCode
|
|
}
|
|
|
|
Exit `$exitCode
|
|
"@
|
|
|
|
$exitCode = 0
|
|
|
|
try {
|
|
# Wait for an interactive user to be logged on
|
|
while ($true) {
|
|
$userName = (Get-CimInstance Win32_ComputerSystem).UserName
|
|
|
|
if ($userName -and $userName -like "*\*") {
|
|
break
|
|
} else {
|
|
Start-Sleep -Seconds 5
|
|
}
|
|
}
|
|
|
|
# Write the install script to disk
|
|
Set-Content -Path $scriptPath -Value $userScript -Force
|
|
|
|
# Build task action: run script (output goes to stdout for Fleet)
|
|
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
|
|
-Argument "-WindowStyle Hidden -ExecutionPolicy Bypass -File `"$scriptPath`""
|
|
|
|
$trigger = New-ScheduledTaskTrigger -AtLogOn
|
|
|
|
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries
|
|
|
|
$principal = New-ScheduledTaskPrincipal -UserId $userName -RunLevel Highest
|
|
|
|
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings -Principal $principal
|
|
|
|
Register-ScheduledTask -TaskName $taskName -InputObject $task -User $userName -Force | Out-Null
|
|
|
|
# Start the task
|
|
Start-ScheduledTask -TaskName $taskName
|
|
|
|
# Wait for it to start
|
|
$startDate = Get-Date
|
|
$state = (Get-ScheduledTask -TaskName $taskName).State
|
|
while ($state -ne "Running") {
|
|
Start-Sleep -Seconds 1
|
|
$elapsed = (New-Timespan -Start $startDate).TotalSeconds
|
|
if ($elapsed -gt 120) { throw "Timeout waiting for task to start." }
|
|
$state = (Get-ScheduledTask -TaskName $taskName).State
|
|
}
|
|
|
|
# Wait for it to complete
|
|
while ($state -eq "Running") {
|
|
Start-Sleep -Seconds 5
|
|
$elapsed = (New-Timespan -Start $startDate).TotalSeconds
|
|
if ($elapsed -gt 120) { throw "Timeout waiting for task to finish." }
|
|
$state = (Get-ScheduledTask -TaskName $taskName).State
|
|
}
|
|
|
|
if (Test-Path $exitCodeFile) {
|
|
$exitCode = Get-Content $exitCodeFile
|
|
} else {
|
|
$exitCode = 1
|
|
}
|
|
|
|
} catch {
|
|
Write-Host "Error: $_"
|
|
$exitCode = 1
|
|
} finally {
|
|
# Clean up
|
|
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
|
|
Remove-Item -Path $scriptPath -Force -ErrorAction SilentlyContinue
|
|
Remove-Item -Path $exitCodeFile -Force -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
Exit $exitCode
|