From 45d358e9d32a6c4e0e39016e2ff283d63ea4502e Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sat, 29 Jul 2023 18:42:06 -0700 Subject: [PATCH] Don't allow a run unless the config files exist. --- Config/DNS/run.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Config/DNS/run.sh b/Config/DNS/run.sh index 3b05686..229fe15 100755 --- a/Config/DNS/run.sh +++ b/Config/DNS/run.sh @@ -9,11 +9,11 @@ function stop-service { if [[ -n $1 ]]; then service=$1 else - echo "ERROR: A parameter was not provided for stop-service, aborting." + echo "ERROR: A parameter was not provided for stop-service, aborting." >&2 exit 1 fi if [[ -n $2 ]]; then - echo "ERROR: A second parameter to stop-service is not expected, aborting." + echo "ERROR: A second parameter to stop-service is not expected, aborting." >&2 exit 1 fi systemctl disable --now $service && @@ -21,6 +21,17 @@ function stop-service { echo "* If $service was not found then there is no problem." } +## Validations ## + +# Ensure the necessary config files have been created. +if [[ ! -s ./config/hosts + || ! -s ./config/resolv.conf + || ! -s ./config/dnsmasq.conf +]]; then + echo "ERROR: Please ensure all 3 files have been created in the config folder." >&2 + exit 1 +fi + echo -e "\n*** Turn off any local DNS programs ***" # These programs use port 53 but this container needs to be able to listen on it. stop-service systemd-resolved