-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added flexibility to restart and clean scripts
- Added logic to extract the name of the parent app running the `restart` and `clean` scripts in the event the app name is changed from `MetricsMetaConfigurationApp`
- Loading branch information
1 parent
87f93c5
commit 4e34975
Showing
2 changed files
with
11 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
### Configure path to restart_check.txt | ||
$scriptAppPath=($MyInvocation.MyCommand.Source) -Replace ("\\bin\\restart.ps1","") | ||
$metaPath = "$SplunkHome\etc\restart_meta.txt" | ||
$restartMeta = $(Test-Path "$SplunkHome\etc\restart_meta.txt" -PathType Leaf) | ||
|
||
### Filter to attach timestamps where necessary | ||
filter timestamp {"$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss.fff') ${env:COMPUTERNAME}: $_"} | ||
|
||
if ($restartMeta -eq "True") { | ||
Write-output "Meta settings has been changed." | timestamp | ||
Write-output "Restarting forwarder." | timestamp | ||
if ($restartMeta -eq "True") { | ||
Remove-Item -path "$metaPath" | ||
} | ||
Remove-Item -path "$SplunkHome\etc\apps\MetricsMetaConfigurationApp\DeleteMeToRestart" | ||
Write-output "Meta settings has been changed." | timestamp | ||
Write-output "Restarting forwarder." | timestamp | ||
if ($restartMeta -eq "True") { | ||
Remove-Item -path "$metaPath" | ||
} | ||
Remove-Item -path "$scriptAppPath\DeleteMeToRestart" | ||
} else { | ||
Write-output "No settings have been changed." | timestamp | ||
Write-output "No restart required." | timestamp | ||
Write-output "No settings have been changed." | timestamp | ||
Write-output "No restart required." | timestamp | ||
} |