From f6f7e691d04f352647429de96baff822c29d5711 Mon Sep 17 00:00:00 2001 From: Matt Darfeuille Date: Mon, 20 Feb 2017 18:51:58 +0100 Subject: [PATCH] Fail if the rc file can not be loaded Signed-off-by: Matt Darfeuille Signed-off-by: Tom Eastep --- Shorewall-core/install.sh | 8 ++++---- Shorewall-core/uninstall.sh | 10 +++++----- Shorewall-init/install.sh | 18 +++++++++--------- Shorewall-init/uninstall.sh | 11 ++++++----- Shorewall-lite/install.sh | 12 +++++++----- Shorewall-lite/uninstall.sh | 11 ++++++----- Shorewall/install.sh | 13 ++++++++----- Shorewall/uninstall.sh | 13 ++++++++----- Shorewall6-lite/uninstall.sh | 11 ++++++----- Shorewall6/uninstall.sh | 10 +++++----- 10 files changed, 64 insertions(+), 53 deletions(-) diff --git a/Shorewall-core/install.sh b/Shorewall-core/install.sh index 6b7bce754..da9be321d 100755 --- a/Shorewall-core/install.sh +++ b/Shorewall-core/install.sh @@ -104,14 +104,14 @@ done # if [ $# -eq 0 ]; then if [ -f ./shorewallrc ]; then - . ./shorewallrc file=./shorewallrc + . $file || fatal_error "Can not load the RC file: $file" elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 file=~/.shorewallrc + . $file || fatal_error "Can not load the RC file: $file" elif [ -f /usr/share/shorewall/shorewallrc ]; then - . /usr/share/shorewall/shorewallrc file=/usr/share/shorewall/shorewallrc + . $file || fatal_error "Can not load the RC file: $file" else fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi @@ -125,7 +125,7 @@ elif [ $# -eq 1 ]; then ;; esac - . $file + . $file || fatal_error "Can not load the RC file: $file" else usage 1 fi diff --git a/Shorewall-core/uninstall.sh b/Shorewall-core/uninstall.sh index 2a12252a9..ef0f3dd8c 100755 --- a/Shorewall-core/uninstall.sh +++ b/Shorewall-core/uninstall.sh @@ -52,11 +52,11 @@ cd "$(dirname $0)" # if [ $# -eq 0 ]; then if [ -f ./shorewallrc ]; then - . ./shorewallrc + . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc" elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 + . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc" elif [ -f /usr/share/shorewall/shorewallrc ]; then - . /usr/share/shorewall/shorewallrc + . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc" else fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi @@ -66,11 +66,11 @@ elif [ $# -eq 1 ]; then /*|.*) ;; *) - file=./$file + file=./$file || exit 1 ;; esac - . $file + . $file || fatal_error "Can not load the RC file: $file" else usage 1 fi diff --git a/Shorewall-init/install.sh b/Shorewall-init/install.sh index 8cbfcb31a..35248fcdc 100755 --- a/Shorewall-init/install.sh +++ b/Shorewall-init/install.sh @@ -114,17 +114,17 @@ done # Read the RC file # if [ $# -eq 0 ]; then - # - # Load packager's settings if any - # if [ -f ./shorewallrc ]; then - . ./shorewallrc || exit 1 file=./shorewallrc + . $file || fatal_error "Can not load the RC file: $file" elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 file=~/.shorewallrc - else - fatal_error "No configuration file specified and ~/.shorewallrc not found" + . $file || fatal_error "Can not load the RC file: $file" + elif [ -f /usr/share/shorewall/shorewallrc ]; then + file=/usr/share/shorewall/shorewallrc + . $file || fatal_error "Can not load the RC file: $file" + else + fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi elif [ $# -eq 1 ]; then file=$1 @@ -132,11 +132,11 @@ elif [ $# -eq 1 ]; then /*|.*) ;; *) - file=./$file + file=./$file || exit 1 ;; esac - . $file + . $file || fatal_error "Can not load the RC file: $file" else usage 1 fi diff --git a/Shorewall-init/uninstall.sh b/Shorewall-init/uninstall.sh index 76de74a5c..e2f64dad8 100755 --- a/Shorewall-init/uninstall.sh +++ b/Shorewall-init/uninstall.sh @@ -83,16 +83,17 @@ while [ $finished -eq 0 ]; do ;; esac done + # # Read the RC file # if [ $# -eq 0 ]; then if [ -f ./shorewallrc ]; then - . ./shorewallrc + . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc" elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 + . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc" elif [ -f /usr/share/shorewall/shorewallrc ]; then - . /usr/share/shorewall/shorewallrc + . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc" else fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi @@ -102,11 +103,11 @@ elif [ $# -eq 1 ]; then /*|.*) ;; *) - file=./$file + file=./$file || exit 1 ;; esac - . $file || exit 1 + . $file || fatal_error "Can not load the RC file: $file" else usage 1 fi diff --git a/Shorewall-lite/install.sh b/Shorewall-lite/install.sh index 020812750..76f8271f6 100755 --- a/Shorewall-lite/install.sh +++ b/Shorewall-lite/install.sh @@ -116,12 +116,14 @@ done # if [ $# -eq 0 ]; then if [ -f ./shorewallrc ]; then - . ./shorewallrc || exit 1 file=./shorewallrc + . $file || fatal_error "Can not load the RC file: $file" elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc + file=~/.shorewallrc + . $file || fatal_error "Can not load the RC file: $file" elif [ -f /usr/share/shorewall/shorewallrc ]; then - . /usr/share/shorewall/shorewallrc + file=/usr/share/shorewall/shorewallrc + . $file || fatal_error "Can not load the RC file: $file" else fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi @@ -131,11 +133,11 @@ elif [ $# -eq 1 ]; then /*|.*) ;; *) - file=./$file + file=./$file || exit 1 ;; esac - . $file + . $file || fatal_error "Can not load the RC file: $file" else usage 1 fi diff --git a/Shorewall-lite/uninstall.sh b/Shorewall-lite/uninstall.sh index 4b5711631..e4f8a2203 100755 --- a/Shorewall-lite/uninstall.sh +++ b/Shorewall-lite/uninstall.sh @@ -87,16 +87,17 @@ while [ $finished -eq 0 ]; do ;; esac done + # # Read the RC file # if [ $# -eq 0 ]; then if [ -f ./shorewallrc ]; then - . ./shorewallrc + . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc" elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 + . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc" elif [ -f /usr/share/shorewall/shorewallrc ]; then - . /usr/share/shorewall/shorewallrc + . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc" else fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi @@ -106,11 +107,11 @@ elif [ $# -eq 1 ]; then /*|.*) ;; *) - file=./$file + file=./$file || exit 1 ;; esac - . $file + . $file || fatal_error "Can not load the RC file: $file" else usage 1 fi diff --git a/Shorewall/install.sh b/Shorewall/install.sh index fccb27812..a28a8dedc 100755 --- a/Shorewall/install.sh +++ b/Shorewall/install.sh @@ -129,11 +129,14 @@ done # if [ $# -eq 0 ]; then if [ -f ./shorewallrc ]; then - . ./shorewallrc + file=./shorewallrc + . $file || fatal_error "Can not load the RC file: $file" elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 + file=~/.shorewallrc + . $file || fatal_error "Can not load the RC file: $file" elif [ -f /usr/share/shorewall/shorewallrc ]; then - . /usr/share/shorewall/shorewallrc + file=/usr/share/shorewall/shorewallrc + . $file || fatal_error "Can not load the RC file: $file" else fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi @@ -143,11 +146,11 @@ elif [ $# -eq 1 ]; then /*|.*) ;; *) - file=./$file + file=./$file || exit 1 ;; esac - . $file + . $file || fatal_error "Can not load the RC file: $file" else usage 1 fi diff --git a/Shorewall/uninstall.sh b/Shorewall/uninstall.sh index f291b7fd4..05e7d7303 100755 --- a/Shorewall/uninstall.sh +++ b/Shorewall/uninstall.sh @@ -88,13 +88,16 @@ while [ $finished -eq 0 ]; do esac done +# +# Read the RC file +# if [ $# -eq 0 ]; then if [ -f ./shorewallrc ]; then - . ./shorewallrc + . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc" elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 + . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc" elif [ -f /usr/share/shorewall/shorewallrc ]; then - . /usr/share/shorewall/shorewallrc + . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc" else fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi @@ -104,11 +107,11 @@ elif [ $# -eq 1 ]; then /*|.*) ;; *) - file=./$file + file=./$file || exit 1 ;; esac - . $file + . $file || fatal_error "Can not load the RC file: $file" else usage 1 fi diff --git a/Shorewall6-lite/uninstall.sh b/Shorewall6-lite/uninstall.sh index 6d0ee50c5..6a302f606 100755 --- a/Shorewall6-lite/uninstall.sh +++ b/Shorewall6-lite/uninstall.sh @@ -83,16 +83,17 @@ while [ $finished -eq 0 ]; do ;; esac done + # # Read the RC file # if [ $# -eq 0 ]; then if [ -f ./shorewallrc ]; then - . ./shorewallrc + . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc" elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 + . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc" elif [ -f /usr/share/shorewall/shorewallrc ]; then - . /usr/share/shorewall/shorewallrc + . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc" else fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi @@ -102,11 +103,11 @@ elif [ $# -eq 1 ]; then /*|.*) ;; *) - file=./$file + file=./$file || exit 1 ;; esac - . $file + . $file || fatal_error "Can not load the RC file: $file" else usage 1 fi diff --git a/Shorewall6/uninstall.sh b/Shorewall6/uninstall.sh index 20ac1c291..b0368a62f 100755 --- a/Shorewall6/uninstall.sh +++ b/Shorewall6/uninstall.sh @@ -89,11 +89,11 @@ done # if [ $# -eq 0 ]; then if [ -f ./shorewallrc ]; then - . ./shorewallrc + . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc" elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 + . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc" elif [ -f /usr/share/shorewall/shorewallrc ]; then - . /usr/share/shorewall/shorewallrc + . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc" else fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi @@ -103,11 +103,11 @@ elif [ $# -eq 1 ]; then /*|.*) ;; *) - file=./$file + file=./$file || exit 1 ;; esac - . $file + . $file || fatal_error "Can not load the RC file: $file" else usage 1 fi