74 lines
2.4 KiB
PowerShell
74 lines
2.4 KiB
PowerShell
# Script to install/update Nextcloud desktop client
|
|
# Technolog Networks - 2025-10-18
|
|
# iRaven
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Updates Nextcloud Client
|
|
.PARAMETER Install
|
|
Boolean to install the client if not installed
|
|
#>
|
|
|
|
param(
|
|
[switch] $Install
|
|
)
|
|
|
|
Start-Transcript -Path "$env:systemdrive\irnh\Nextcloud-Updater.log" -Append
|
|
$PkgInfo = Get-Package -Name "Nextcloud*"
|
|
$LatestVerResp = (irm https://api.github.com/repos/nextcloud-releases/desktop/releases/latest)
|
|
$LatestVer = $LatestVerResp.tag_name
|
|
$LatestVerURL = $LatestVerResp.assets.browser_download_url -like "*.msi"
|
|
$InstallerFile = "$env:systemdrive\irnh\Nextcloud-$LatestVer.msi"
|
|
|
|
Function IsLatestVer {
|
|
# What kind of fuckery is this. I hate it (compares [v]1.2.3 to 1.2.3[.20250123])
|
|
if (($LatestVer.Substring(1)) -gt ($PkgInfo.Version.Substring(0,6))){
|
|
return $false
|
|
} else {
|
|
return $true
|
|
}
|
|
}
|
|
|
|
Function DownloadLatestVer {
|
|
try {
|
|
if (!(Test-Path $InstallerFile)) {
|
|
cmd.exe /c "curl -L -o $InstallerFile $LatestVerURL"
|
|
}
|
|
} catch {
|
|
write-host -ForegroundColor red "Couldn't download the latest installer at URL $LatestVerURL !"
|
|
}
|
|
}
|
|
|
|
Function InstallLatestVer {
|
|
try {
|
|
Write-Host -ForegroundColor Yellow "Installing Nextcloud Client $LatestVer"
|
|
$NCInstall = Start-Process msiexec -Wait -PassThru -ArgumentList "/passive /i $InstallerFile REBOOT=ReallySuppress"
|
|
write-host "returned exit code" $NCInstall.ExitCode
|
|
if (0 -in $NCInstall.ExitCode) {
|
|
Write-Host -ForegroundColor Green "Successfully installed!"
|
|
rm $InstallerFile
|
|
}
|
|
} catch {
|
|
write-host "it no worky"
|
|
}
|
|
}
|
|
|
|
if (!($PkgInfo) -and !($Install)) { # Not installed, no install flag
|
|
Write-Host -ForegroundColor Yellow "Nextcloud not installed & not installing it."
|
|
} elseif (!($PkgInfo) -and $Install) { # Not installed, with install flag
|
|
Write-Host -ForegroundColor Yellow "Nextcloud not installed - installing latest version $LatestVer"
|
|
DownloadLatestVer
|
|
InstallLatestVer
|
|
} else {
|
|
Write-Host -ForegroundColor Yellow "Nextcloud installed with" $PkgInfo.Version
|
|
if (IsLatestVer) {
|
|
Write-Host -ForegroundColor Green "The currently installed version is the latest version"
|
|
} else {
|
|
Write-Host -ForegroundColor Yellow "The currently installed version is NOT the latest version - installing $LatestVer"
|
|
DownloadLatestVer
|
|
InstallLatestVer
|
|
}
|
|
}
|
|
|
|
Write-Host "Exiting"
|
|
Stop-Transcript |