Skip to content

Commit 18a08a9

Browse files
Update for reading app context
To allow for the app to be rename but retain functionallity of the restart script, the restart scripts have been designed to take their parent directories into account and replace the removal path of "DeleteMeToRestart" to match the app name. To make this easier to do, the "DeleteMeToRestart" file has been moved to the "bin" directory with the scripts.
1 parent b7b3a82 commit 18a08a9

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed
File renamed without changes.

bin/appContext.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
## Grab the current app context
3+
SCRIPT_PATH=$(realpath $0)
4+
APP_PATH=$(dirname ${SCRIPT_PATH})

bin/restart.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ if ($restartInput -eq "True" -OR $restartServer -eq "True" -OR $restartDS -eq "T
3131
if ($restartDateTime -eq "True") {
3232
Remove-Item -path "$dateTimePath"
3333
}
34-
Remove-Item -path "$SPLUNKHOME\etc\apps\SplunkForwarderRepairKit\DeleteMeToRestart"
34+
Remove-Item -path "$PSScriptRoot\DeleteMeToRestart"
3535
} else {
3636
Write-output "No settings have been changed." | timestamp
3737
Write-output "No restart required." | timestamp
38-
}
38+
}

bin/restart.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
2+
### Source the appPath script to pull proper app context
3+
source appContext.sh
4+
25
### Configure the path to the restart_check.txt file on the system
36
RESTARTINPUT="$SPLUNK_HOME/etc/restartinput.txt"
47
RESTARTSERVER="$SPLUNK_HOME/etc/restartserver.txt"
@@ -25,7 +28,7 @@ if [ -f "$RESTARTINPUT" ] || [ -f "$RESTARTSERVER" ] || [ -f "$RESTARTDS" ] || [
2528
if [ -f "$RESTARTDATETIME" ]; then
2629
rm -f "$RESTARTDATETIME"
2730
fi
28-
rm -f $SPLUNK_HOME/etc/apps/SplunkForwarderRepairKit/DeleteMeToRestart
31+
rm -f "${APP_PATH}/DeleteMeToRestart"
2932
else
3033
echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") ${HOSTNAME}: No settings have been changed."
3134
echo "$(date +"%Y-%m-%d %H:%M:%S.%3N") ${HOSTNAME}: No restart required."

0 commit comments

Comments
 (0)