diff --git a/Scripts/Deploy-NewBuild.ps1 b/Scripts/Deploy-NewBuild.ps1 deleted file mode 100644 index 8963a71659d7f89eaace54407bd5efbfdf50423a..0000000000000000000000000000000000000000 --- a/Scripts/Deploy-NewBuild.ps1 +++ /dev/null @@ -1,36 +0,0 @@ -# Helper script to facilitate the package-deploy-update cycle. Its purpose is to -# automate reading the updater config (optionally just using the default -# location) and subsequently call the `Make-Package.ps1` and -# `Provide-UpdaterPackage.ps1` scripts followed by a removal of the update -# marker file for the local computer, all using the parameters collected from -# the configuration file. - -[CmdletBinding()] -Param( - [String] $UpdaterSettings = "C:\Tools\AutoTx-Updater\UpdaterConfig.inc.ps1" -) - -$ErrorActionPreference = "Stop" - -try { - . $UpdaterSettings -} -catch { - $ex = $_.Exception.Message - Write-Host "Error reading settings file: '$($UpdaterSettings)' [$($ex)]" - Exit -} - -# Make sure to run from the directory containing the script itself: -$BaseDir = $(Split-Path $MyInvocation.MyCommand.Path) -Push-Location $BaseDir - -.\Make-Package.ps1 -.\Provide-UpdaterPackage.ps1 -UpdaterSettings $UpdaterSettings - -$Marker = "$($UpdateSourcePath)\Service\UpdateMarkers\$($env:COMPUTERNAME)" -if (Test-Path $Marker) { - Remove-Item -Force -Verbose $Marker -} - -Pop-Location \ No newline at end of file diff --git a/Scripts/Install-NewestPackage.ps1 b/Scripts/Install-NewestPackage.ps1 deleted file mode 100644 index 2dc864c0b219d2d6fe70eb6b7e4e3857123a5367..0000000000000000000000000000000000000000 --- a/Scripts/Install-NewestPackage.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -# Helper script to locate the latest AutoTx installation package (expected to be -# in a subdirectory of this script with a name like `build_2019-04-23_12-34-56`) -# and call the installer script from *within* that package. - -# Make sure to run from the directory containing the script itself: -$BaseDir = $(Split-Path $MyInvocation.MyCommand.Path) -Push-Location $BaseDir - - -$PackageDir = Get-ChildItem -Directory -Name | - Where-Object {$_ -match 'build_[0-9]{4}-[0-9]{2}-[0-9]{2}_'} | - Sort-Object | - Select-Object -Last 1 - - -Write-Host -NoNewLine "Installing package [" -Write-Host -NoNewLine $PackageDir -Fore Green -Write-Host "] ..." -Write-Host "" - -cd $PackageDir -./Install-Service.ps1 - -# Return to the original location before the script was called: -Pop-Location \ No newline at end of file diff --git a/Scripts/Install-Service.ps1 b/Scripts/Install-Service.ps1 deleted file mode 100644 index a5f23c4d3afa8183652066aecd61ad56c330a014..0000000000000000000000000000000000000000 --- a/Scripts/Install-Service.ps1 +++ /dev/null @@ -1,120 +0,0 @@ -# Helper script to install the AutoTx service on a computer. It is intended to -# be run from *within* an AutoTx installation package created with the -# `Make-Package.ps1` script. -# -# NOTE: the script will NOT update an existing installation of AutoTx! - -# set our requirements: -#Requires -version 5.1 -#Requires -RunAsAdministrator - -[CmdletBinding()] -Param( - [Parameter(Mandatory = $False)][switch] $StartService -) - -function Start-MyService { - Write-Host -NoNewLine "Starting service $($ServiceName): " - try { - Start-Service $ServiceName - Write-Host "[OK]" -Fore Green - } catch { - $ex = $_.Exception - Write-Host "[FAILED]" -Fore Red - Write-Host $ex.Message - Write-Host "Please check if your configuration is valid!" - Write-Host "Showing last 20 lines of service log file:" - Write-Host "==========================================" - Get-Content $ServiceLog -Tail 20 - } -} - - -function Copy-ServiceFiles { - if (Test-Path -Type Container $ServiceDir) { - Write-Host "Target directory [$($ServiceDir)] exists, stopping!" - Exit 1 - } - - Write-Host -NoNewLine "Updating / installing service files: " - $TargetDir = New-Item -ItemType Container -Force -Path $ServiceDir - try { - Copy-Item -Recurse -Force -Path "$ServiceName\*" -Destination $ServiceDir - Copy-Item -Recurse -Force -Path "conf-example" -Destination $ServiceDir - # create a dummy log file, so admins can already start watching it: - Out-File -FilePath $ServiceLog -InputObject "$($ServiceName) installed" -Encoding utf8 - Write-Host "[OK]" -Fore Green - } catch { - $ex = $_.Exception - Write-Host "[FAILED]" -Fore Red - Write-Host $ex.Message - Exit - } -} - - -function Install-Service { - Write-Host "Installing service $($ServiceName)... " - Write-Host "========================================================================" - $InstallUtil = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" - $ServiceExe = $ServiceDir + "\" + $ServiceName + ".exe" - $ArgList = ("/username=$ServiceUser", "/password=$ServicePasswd", "/unattended", "$ServiceExe") - $InstallProcess = Start-Process -FilePath "$InstallUtil" -ArgumentList $ArgList -Wait -NoNewWindow -PassThru - Write-Host "========================================================================" - Write-Host "InstallUtil exit code: $($InstallProcess.ExitCode)" - Write-Host "========================================================================" -} - - -function Add-PerfMonGroupMember { - $GroupName = "Performance Monitor Users" - try { - Add-LocalGroupMember -Group $GroupName -Member $ServiceUser - Write-Host $("Successfully added user [$($ServiceUser)] to the local" - "group [$($GroupName)].") - } catch [Microsoft.PowerShell.Commands.MemberExistsException] { - Write-Host $("User [$($ServiceUser)] is already a member of the local" - "group [$($GroupName)], no action required.") - } catch { - Write-Host $("Adding user [$($ServiceUser)] to the local group" - "[$($GroupName)] failed: $($_.Exception.Message)") - } -} - - -$ErrorActionPreference = "Stop" - - -$LocalConfiguration = ".\ScriptsConfig.ps1" -if (Test-Path $LocalConfiguration) { - . $LocalConfiguration -} else { - Write-Host "Can't find configuration '$LocalConfiguration'!" -Fore Red - Exit -} - -$ServiceLog = "$($ServiceDir)\var\$($env:COMPUTERNAME).$($ServiceName).log" - - -$Service = Get-Service $ServiceName -ErrorAction SilentlyContinue -if ($Service) { - Write-Host "Service $($ServiceName) already installed! Please use the" ` - "Updater to do service updates. Stopping." - Exit 1 -} - -Copy-ServiceFiles -Install-Service -Add-PerfMonGroupMember - -Write-Host "`nWatching the service log file can be done like this:`n" ` - "`n> Get-Content -Wait -Tail 50 $($ServiceLog)`n" - -if ($StartService) { - Start-MyService -} else { - Write-Host "Service installation has completed.`n" ` - "`nNOTE: the service has not been started. Create and/or check`n" ` - "the configuration files and start the service manually using:`n" ` - "`n> Start-Service $($ServiceName)`n" -} \ No newline at end of file diff --git a/Scripts/Provide-UpdaterPackage.ps1 b/Scripts/Provide-UpdaterPackage.ps1 deleted file mode 100644 index 0c337980bb9389d00ab16b33ef088fcda17ae2f1..0000000000000000000000000000000000000000 --- a/Scripts/Provide-UpdaterPackage.ps1 +++ /dev/null @@ -1,61 +0,0 @@ -# Helper script to locate the latest AutoTx installation package (expected to be -# in a subdirectory of this script with a name like `build_2019-04-23_12-34-56`) -# and copy it to the correct path so it can be picked up the AutoTx-Updater. -# -# NOTE: the script will prune a few files (currently hardcoded) from the package -# copied to the central update location to prevent sensitive information from -# being accidentially leaked through a publicly accessible location (see the -# `$Exclude` variable below). - - -[CmdletBinding()] -Param( - [Parameter(Mandatory=$True)][String] $UpdaterSettings -) - - -try { - . $UpdaterSettings -} -catch { - $ex = $_.Exception.Message - Write-Host "Error reading settings file: '$($UpdaterSettings)' [$($ex)]" - Exit -} - - -# Make sure to run from the directory containing the script itself: -$BaseDir = $(Split-Path $MyInvocation.MyCommand.Path) -Push-Location $BaseDir - - -$UpdateBinariesPath = "$($UpdateSourcePath)\Service\Binaries" - -$PackageDir = Get-ChildItem -Directory -Name | - Where-Object {$_ -match $Pattern} | - Sort-Object | - Select-Object -Last 1 - -if ([string]::IsNullOrEmpty($PackageDir)) { - Write-Host "ERROR: couldn't find any directories matching '$($Pattern)'!" - Exit -} - - -try { - # exclude some files not be distributed: - $Exclude = @("ScriptsConfig.ps1", "Install-Service.ps1") - Copy-Item -Recurse -Force -ErrorAction Stop ` - -Path $PackageDir ` - -Exclude $Exclude ` - -Destination $UpdateBinariesPath - Write-Host "Copied package [$($PackageDir)] to [$($UpdateBinariesPath)]." -} -catch { - $ex = $_.Exception.Message - Write-Host "Error copying service package: $($ex)" - Exit -} - -# Return to the original location before the script was called: -Pop-Location \ No newline at end of file diff --git a/Scripts/Run-ElevatedPowerShell.ps1 b/Scripts/Run-ElevatedPowerShell.ps1 deleted file mode 100644 index 2ddae00be9ab89a5132e26cfe2400f9ef1a67a5d..0000000000000000000000000000000000000000 --- a/Scripts/Run-ElevatedPowerShell.ps1 +++ /dev/null @@ -1 +0,0 @@ -Start-Process powershell.exe -ArgumentList '-noprofile' -Verb RunAs diff --git a/Scripts/ScriptsConfig-Example.ps1 b/Scripts/ScriptsConfig-Example.ps1 deleted file mode 100644 index cc10b83537895a997354e852eca3d5c821981696..0000000000000000000000000000000000000000 --- a/Scripts/ScriptsConfig-Example.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -$ServiceName = "AutoTx" -$ServiceDir = "C:\Tools\$($ServiceName)" - -$ManagedDir = "D:\ProgramData\AUTOTRANSFER" -$IncomingDir = "$($ManagedDir)\INCOMING" - -$ServiceUser = "DOMAIN\serviceuser" -$ServicePasswd = "mycomplexpassword" \ No newline at end of file diff --git a/Scripts/Trigger-Updater.ps1 b/Scripts/Trigger-Updater.ps1 deleted file mode 100644 index 5d0cac65fa807c4f827ce8bf32ea7c067f22d200..0000000000000000000000000000000000000000 --- a/Scripts/Trigger-Updater.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -# Helper script to trigger the updater if the corresponding marker file has -# been removed (e.g. by using the `Deploy-NewBuild.ps1` script). - -#Requires -RunAsAdministrator - -[CmdletBinding()] -Param( - [String] $UpdaterSettings = "C:\Tools\AutoTx-Updater\UpdaterConfig.inc.ps1" -) - -$ErrorActionPreference = "Stop" - -try { - . $UpdaterSettings -} -catch { - $ex = $_.Exception.Message - Write-Host "Error reading settings file: '$($UpdaterSettings)' [$($ex)]" - Exit -} - -$Marker = "$($UpdateSourcePath)\Service\UpdateMarkers\$($env:COMPUTERNAME)" -Write-Host "Using marker file $Marker" - -while ($true) { - if (Test-Path $Marker) { - # Write-Host "marker file found" - } else { - # Write-Host "NO marker file found, starting updater..." - (Get-ScheduledJob -Name "AutoTx-Updater").StartJob() - # Allow the updater to complete its run: - Start-Sleep 30 - } - Start-Sleep 1 -} \ No newline at end of file diff --git a/Scripts/Uninstall-Service.ps1 b/Scripts/Uninstall-Service.ps1 deleted file mode 100644 index fa954b52df820a299964646534f49103760cf4d7..0000000000000000000000000000000000000000 --- a/Scripts/Uninstall-Service.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -$LocalConfiguration = ".\ScriptsConfig.ps1" -if (Test-Path $LocalConfiguration) { - . $LocalConfiguration -} else { - Write-Host "Can't find configuration '$LocalConfiguration'!" -Fore Red - Exit -} -Write-Host "Loaded configuration '$LocalConfiguration'." -Fore Green -Write-Host $ServiceDir -Write-Host $SourceDir - -Push-Location "C:\Windows\Microsoft.NET\Framework\v4.0.30319" - -$ServiceExe = $ServiceDir + "\" + $ServiceName + ".exe" -.\InstallUtil.exe -u $ServiceExe - -Pop-Location \ No newline at end of file diff --git a/Scripts/Watch-Logfile.ps1 b/Scripts/Watch-Logfile.ps1 deleted file mode 100644 index 799d467fba89ab4f80beb904365c874f3889204c..0000000000000000000000000000000000000000 --- a/Scripts/Watch-Logfile.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -# Make sure to run from the directory containing the script itself: -$BaseDir = $(Split-Path $MyInvocation.MyCommand.Path) -Push-Location $BaseDir - -$LocalConfiguration = ".\ScriptsConfig.ps1" -if (Test-Path $LocalConfiguration) { - . $LocalConfiguration -} else { - Write-Host "Can't find configuration '$LocalConfiguration'!" -Fore Red - Exit -} - -$LogFile = "$($ServiceDir)\var\$($env:COMPUTERNAME).$($ServiceName).log" - -if (Test-Path $LogFile) { - Write-Host "Watching logfile '$LogFile':" - Get-Content -Tail 200 -Wait $LogFile -} else { - Write-Host "Logfile '$LogFile' doesn't exist." -} - -Pop-Location \ No newline at end of file