From 76b356133630f6c258a55b857d5da48c90dd044c Mon Sep 17 00:00:00 2001 From: Andy Thompson Date: Wed, 21 Feb 2024 10:50:39 +0000 Subject: [PATCH] Add standard bash error handling options --- home/bin/ws-poweroff | 4 +++- home/bin/ws-service | 6 +++++- home/service/logger/init.sh | 6 +++++- home/service/mail/init.sh | 6 +++++- home/service/proxy/init.sh | 4 +++- home/service/tracing/init.sh | 4 +++- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/home/bin/ws-poweroff b/home/bin/ws-poweroff index cdf3e552..4ca10c0e 100755 --- a/home/bin/ws-poweroff +++ b/home/bin/ws-poweroff @@ -1,6 +1,8 @@ #!/bin/bash -set -e -o pipefail +set -o errexit +set -o nounset +set -o pipefail DIR="" diff --git a/home/bin/ws-service b/home/bin/ws-service index 062491ec..09175bca 100755 --- a/home/bin/ws-service +++ b/home/bin/ws-service @@ -1,5 +1,9 @@ #!/bin/bash +set -o errexit +set -o nounset +set -o pipefail + DIR="" TRAEFIK_NETWORK="my127ws" @@ -34,7 +38,7 @@ bootstrap() return fi - if ! docker network ls | grep "${TRAEFIK_NETWORK}" > /dev/null; then + if ! docker network inspect "${TRAEFIK_NETWORK}" > /dev/null; then run docker network create "$TRAEFIK_NETWORK" fi } diff --git a/home/service/logger/init.sh b/home/service/logger/init.sh index 87f604ba..c1b91aec 100755 --- a/home/service/logger/init.sh +++ b/home/service/logger/init.sh @@ -1,5 +1,9 @@ #!/bin/bash +set -o errexit +set -o nounset +set -o pipefail + DIR="" main() @@ -36,7 +40,7 @@ bootstrap() # shellcheck source=../../lib/sidekick.sh source "$DIR/../../lib/sidekick.sh" - cd "$DIR" || exit 1 + cd "$DIR" } bootstrap diff --git a/home/service/mail/init.sh b/home/service/mail/init.sh index 3345028a..1e10f2f2 100755 --- a/home/service/mail/init.sh +++ b/home/service/mail/init.sh @@ -1,5 +1,9 @@ #!/bin/bash +set -o errexit +set -o nounset +set -o pipefail + DIR="" main() @@ -36,7 +40,7 @@ bootstrap() # shellcheck source=../../lib/sidekick.sh source "$DIR/../../lib/sidekick.sh" - cd "$DIR" || exit 1 + cd "$DIR" } bootstrap diff --git a/home/service/proxy/init.sh b/home/service/proxy/init.sh index 87c70b73..2a7da233 100755 --- a/home/service/proxy/init.sh +++ b/home/service/proxy/init.sh @@ -1,6 +1,8 @@ #!/bin/bash -set -e +set -o errexit +set -o nounset +set -o pipefail DIR="" diff --git a/home/service/tracing/init.sh b/home/service/tracing/init.sh index c00ba0eb..0b6ac962 100755 --- a/home/service/tracing/init.sh +++ b/home/service/tracing/init.sh @@ -1,6 +1,8 @@ #!/bin/bash -set -e +set -o errexit +set -o nounset +set -o pipefail DIR=""