mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-19 02:47:45 +00: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:
@@ -26,6 +26,7 @@
|
|||||||
#CurlRetryDelay=1 # Time between curl retries
|
#CurlRetryDelay=1 # Time between curl retries
|
||||||
#CurlRetryCount=3 # Max number of curl retries
|
#CurlRetryCount=3 # Max number of curl retries
|
||||||
#CurlConnectTimeout=5 # Time to wait for curl to establish a connection before failing
|
#CurlConnectTimeout=5 # Time to wait for curl to establish a connection before failing
|
||||||
|
#DisplaySourcedFiles=false # Display what files are being sourced/used
|
||||||
|
|
||||||
### Notify settings
|
### Notify settings
|
||||||
## All commented values are examples only. Modify as needed.
|
## 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")"
|
ScriptWorkDir="$(dirname "$ScriptPath")"
|
||||||
|
|
||||||
# Source helper functions
|
# Source helper functions
|
||||||
source_if_exists() {
|
|
||||||
if [[ -s "$1" ]]; then source "$1"; fi
|
|
||||||
}
|
|
||||||
|
|
||||||
source_if_exists_or_fail() {
|
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
|
# 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 Function
|
||||||
Help() {
|
Help() {
|
||||||
|
|||||||
Reference in New Issue
Block a user