Skip to content

Commit

Permalink
Add EULA global acceptance
Browse files Browse the repository at this point in the history
Accepting the EULA during setup should now. Enabled Skip Update option
  • Loading branch information
DChorn-ANS committed Sep 11, 2024
1 parent c1b5aa7 commit 6bd0314
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
14 changes: 9 additions & 5 deletions Osprey/functions/General/Start-Osprey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 141,7 @@ Function Get-Eula {
switch ($result) {
0 {
Write-Information "`n"
Add-OspreyAppData -Name "IAgreeToTheEula" -Value $true -SkipLogging
}
1 {
Write-Information "Aborting Cmdlet"
Expand All @@ -155,6 155,9 @@ Function Get-Eula {
###MAIN###

Function Start-Osprey {
param(
[switch]$SkipUpdate
)
#some helpful comment here
$InformationPreference = "Continue"
$OspreyInitialized = $false
Expand Down Expand Up @@ -241,19 244,20 @@ Function Start-Osprey {
}


<#EULA stuff. Should only ever do this ONCE per Osprey install! but is broken.
#EULA stuff. Should only ever do this ONCE per Osprey install! but is broken.
if ($OspreyInitialized -ne $true) {
#gets EULA info from appdata variable
Read-OspreyAppData
if ($null -eq $OspreyAppData.IAgreeToTheEula) {
Write-Information "You must agree with the EULA to continue"
Get-Eula
}
else {
Write-Information "Already agreed to the EULA"
}
}#>
}

Get-Eula
#Get-Eula

Write-Information "Setting Up Osprey environment"

Expand Down Expand Up @@ -361,7 365,7 @@ Function Start-Osprey {


# Determine if we have access to a P1 or P2 Azure Ad License
if ([bool] (Get-MgSubscribedSku | Where-Object { ($_.SkuPartNumber -like "*aad_premium*") -or ($_.SkuPartNumber -like "*EMS*") -or ($_.SkuPartNumber -like "*E5*") -or ($_.SkuPartNumber -like "*G5*") -or ($_.SkuPartNumber -like "*SPB*") -or ($_.SkuPartNumber -like "*A3*") -or ($_.SkuPartNumber -like "*A5*") -or ($_.SkuPartNumber -like "*F1*")} )) {
if ([bool] (Get-MgSubscribedSku | Where-Object { ($_.SkuPartNumber -like "*aad_premium*") -or ($_.SkuPartNumber -like "*EMS*") -or ($_.SkuPartNumber -like "*E5*") -or ($_.SkuPartNumber -like "*G5*") -or ($_.SkuPartNumber -like "*SPB*") -or ($_.SkuPartNumber -like "*A3*") -or ($_.SkuPartNumber -like "*A5*") -or ($_.SkuPartNumber -like "*F1*") } )) {
Write-Information "Advanced Entra ID License Found"
[bool]$AdvancedEntraLicense = $true
}
Expand Down
12 changes: 7 additions & 5 deletions Osprey/internal/functions/Add-OspreyAppData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 21,23 @@ Function Add-OspreyAppData {
param
(
[string]$Name,
[string]$Value
[string]$Value,
[switch]$SkipLogging

)

Out-LogFile ("Adding " $value " to " $Name " in OspreyAppData")
if (!$SkipLogging) { Out-LogFile ("Adding " $value " to " $Name " in OspreyAppData") }

# Test if our OspreyAppData variable exists
if ([bool](get-variable OspreyAppData -ErrorAction SilentlyContinue)) {
$global:OspreyAppData | Add-Member -MemberType NoteProperty -Name $Name -Value $Value
if ($ospreyappdata) {
$global:OspreyAppData | Add-Member -MemberType NoteProperty -Name $Name -Value $Value -ErrorAction SilentlyContinue
}
else {
$global:OspreyAppData = New-Object -TypeName PSObject
$global:OspreyAppData | Add-Member -MemberType NoteProperty -Name $Name -Value $Value
}

# make sure we then write that out to the appdata storage
Out-OspreyAppData
if ($SkipLogging) { Out-OspreyAppData -SkipLogging }else { Out-OspreyAppData }

}
10 changes: 7 additions & 3 deletions Osprey/internal/functions/Out-OspreyAppData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 14,12 @@
General notes
#>
Function Out-OspreyAppData {
$OspreyAppdataPath = join-path $env:LOCALAPPDATA "Osprey\Osprey.json"
$OspreyAppdataFolder = join-path $env:LOCALAPPDATA "Osprey"
param(
[switch]$SkipLogging
)
$OspreyAppdataFolder = $env:LOCALAPPDATA "\Osprey"
$OspreyAppdataPath = $OspreyAppdataFolder "\Osprey.json"


# test if the folder exists
if (test-path $OspreyAppdataFolder) { }
Expand All @@ -24,6 28,6 @@ Function Out-OspreyAppData {
$null = New-Item -ItemType Directory -Path $OspreyAppdataFolder
}

Out-LogFile ("Recording OspreyAppData to file " $OspreyAppdataPath)
if (!$SkipLogging) { Out-LogFile ("Recording OspreyAppData to file " $OspreyAppdataPath) }
$global:OspreyAppData | ConvertTo-Json | Out-File -FilePath $OspreyAppdataPath -Force
}
17 changes: 8 additions & 9 deletions Osprey/internal/functions/Read-OspreyAppData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 14,14 @@
General notes
#>
Function Read-OspreyAppData {
$OspreyAppdataPath = join-path $env:LOCALAPPDATA "Osprey\Osprey.json"

# check to see if our xml file is there
param(
[switch]$SkipLogging
)

$OspreyAppdataPath = $env:LOCALAPPDATA "Osprey\Osprey.json"
# check to see if our json file is there
if (test-path $OspreyAppdataPath) {
Out-LogFile ("Reading file " $OspreyAppdataPath)
$global:OspreyAppData = ConvertFrom-Json -InputObject ([string](Get-Content $OspreyAppdataPath))
}
# if we don't have an xml file then do nothing
else {
Out-LogFile ("No OspreyAppData File found " $OspreyAppdataPath)
if (!$SkipLogging) { Out-LogFile ("Reading file " $OspreyAppdataPath) }
$global:OspreyAppData = Get-Content $OspreyAppdataPath | ConvertFrom-Json
}
}

0 comments on commit 6bd0314

Please sign in to comment.