Skip to content
Snippets Groups Projects
Commit 0131c266 authored by Michael Mell's avatar Michael Mell
Browse files

Delete obsolete scripts.

parent ce71c8a4
Branches
No related tags found
No related merge requests found
# 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
# 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
# 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
# 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
Start-Process powershell.exe -ArgumentList '-noprofile' -Verb RunAs
$ServiceName = "AutoTx"
$ServiceDir = "C:\Tools\$($ServiceName)"
$ManagedDir = "D:\ProgramData\AUTOTRANSFER"
$IncomingDir = "$($ManagedDir)\INCOMING"
$ServiceUser = "DOMAIN\serviceuser"
$ServicePasswd = "mycomplexpassword"
\ No newline at end of file
# 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
$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
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment