mirror of
https://github.com/mag37/dockcheck.git
synced 2026-02-14 23:38:15 +01:00
Add DisplaySourcedFiles variable (#207)
* Add DisplaySourcedFiles variable to be used in source_if_exists and source_if_exists_or_fail functions * Added return 0 as to not throw wrong exit code. * Delete source_if_exists. source_if_exists_or_fail returns success or failure. Failure doesn't stop the script --------- Co-authored-by: Elephant Quater <eq@cont.MSHOME> Co-authored-by: mag37 <robin.ivehult@gmail.com>
This commit is contained in:
parent
d37e1a1024
commit
69c06de1bd
2 changed files with 9 additions and 6 deletions
|
|
@ -26,6 +26,7 @@
|
|||
#CurlRetryDelay=1 # Time between curl retries
|
||||
#CurlRetryCount=3 # Max number of curl retries
|
||||
#CurlConnectTimeout=5 # Time to wait for curl to establish a connection before failing
|
||||
#DisplaySourcedFiles=false # Display what files are being sourced/used
|
||||
|
||||
### Notify settings
|
||||
## All commented values are examples only. Modify as needed.
|
||||
|
|
|
|||
14
dockcheck.sh
14
dockcheck.sh
|
|
@ -14,16 +14,18 @@ ScriptPath="$(readlink -f "$0")"
|
|||
ScriptWorkDir="$(dirname "$ScriptPath")"
|
||||
|
||||
# Source helper functions
|
||||
source_if_exists() {
|
||||
if [[ -s "$1" ]]; then source "$1"; fi
|
||||
}
|
||||
|
||||
source_if_exists_or_fail() {
|
||||
[[ -s "$1" ]] && source "$1"
|
||||
if [[ -s "$1" ]]; then
|
||||
source "$1"
|
||||
[[ "${DisplaySourcedFiles:-false}" == true ]] && echo " * sourced config: ${1}"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# User customizable defaults
|
||||
source_if_exists_or_fail "${HOME}/.config/dockcheck.config" || source_if_exists "${ScriptWorkDir}/dockcheck.config"
|
||||
source_if_exists_or_fail "${HOME}/.config/dockcheck.config" || source_if_exists_or_fail "${ScriptWorkDir}/dockcheck.config"
|
||||
|
||||
# Help Function
|
||||
Help() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue