From 4e771083c7fadd2dfcf7f5b72334c6a93c69030d Mon Sep 17 00:00:00 2001 From: Matt Darfeuille Date: Mon, 20 Feb 2017 18:51:49 +0100 Subject: [PATCH] Load installers's common functions Signed-off-by: Matt Darfeuille Signed-off-by: Tom Eastep --- Shorewall-core/install.sh | 48 ++++----------------------------- Shorewall-init/install.sh | 49 ++++------------------------------ Shorewall-lite/install.sh | 56 ++++----------------------------------- Shorewall/install.sh | 47 ++++---------------------------- 4 files changed, 20 insertions(+), 180 deletions(-) diff --git a/Shorewall-core/install.sh b/Shorewall-core/install.sh index 6e4a13101..e6b056c58 100755 --- a/Shorewall-core/install.sh +++ b/Shorewall-core/install.sh @@ -36,50 +36,12 @@ usage() # $1 = exit status exit $1 } -fatal_error() -{ - echo " ERROR: $@" >&2 - exit 1 -} - -split() { - local ifs - ifs=$IFS - IFS=: - set -- $1 - echo $* - IFS=$ifs -} - -qt() -{ - "$@" >/dev/null 2>&1 -} - -mywhich() { - local dir - - for dir in $(split $PATH); do - if [ -x $dir/$1 ]; then - echo $dir/$1 - return 0 - fi - done - - return 2 -} - cant_autostart() { echo echo "WARNING: Unable to configure shorewall to start automatically at boot" >&2 } -delete_file() # $1 = file to delete -{ - rm -f $1 -} - install_file() # $1 = source $2 = target $3 = mode { if cp -f $1 $2; then @@ -98,16 +60,16 @@ install_file() # $1 = source $2 = target $3 = mode exit 1 } -require() -{ - eval [ -n "\$$1" ] || fatal_error "Required option $1 not set" -} - # # Change to the directory containing this script # cd "$(dirname $0)" +# +# Source common functions +# +. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; } + # # Parse the run line # diff --git a/Shorewall-init/install.sh b/Shorewall-init/install.sh index 937131ef8..4ff3ee6ac 100755 --- a/Shorewall-init/install.sh +++ b/Shorewall-init/install.sh @@ -41,38 +41,6 @@ usage() # $1 = exit status exit $1 } -fatal_error() -{ - echo " ERROR: $@" >&2 - exit 1 -} - -split() { - local ifs - ifs=$IFS - IFS=: - set -- $1 - echo $* - IFS=$ifs -} - -qt() -{ - "$@" >/dev/null 2>&1 -} - -mywhich() { - local dir - - for dir in $(split $PATH); do - if [ -x $dir/$1 ]; then - return 0 - fi - done - - return 2 -} - cant_autostart() { echo @@ -97,23 +65,16 @@ install_file() # $1 = source $2 = target $3 = mode exit 1 } -make_directory() # $1 = directory , $2 = mode -{ - mkdir -p $1 - chmod 0755 $1 - [ -n "$OWNERSHIP" ] && chown $OWNERSHIP $1 -} - -require() -{ - eval [ -n "\$$1" ] || fatal_error "Required option $1 not set" -} - # # Change to the directory containing this script # cd "$(dirname $0)" +# +# Source common functions +# +. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; } + # # Parse the run line # diff --git a/Shorewall-lite/install.sh b/Shorewall-lite/install.sh index adc239083..92fe21912 100755 --- a/Shorewall-lite/install.sh +++ b/Shorewall-lite/install.sh @@ -34,50 +34,12 @@ usage() # $1 = exit status exit $1 } -fatal_error() -{ - echo " ERROR: $@" >&2 - exit 1 -} - -split() { - local ifs - ifs=$IFS - IFS=: - set -- $1 - echo $* - IFS=$ifs -} - -qt() -{ - "$@" >/dev/null 2>&1 -} - -mywhich() { - local dir - - for dir in $(split $PATH); do - if [ -x $dir/$1 ]; then - echo $dir/$1 - return 0 - fi - done - - return 2 -} - cant_autostart() { echo echo "WARNING: Unable to configure $Product to start automatically at boot" >&2 } -delete_file() # $1 = file to delete -{ - rm -f $1 -} - install_file() # $1 = source $2 = target $3 = mode { if cp -f $1 $2; then @@ -96,19 +58,6 @@ install_file() # $1 = source $2 = target $3 = mode exit 1 } -make_directory() # $1 = directory , $2 = mode -{ - mkdir -p $1 - chmod 755 $1 - [ -n "$OWNERSHIP" ] && chown $OWNERSHIP $1 - -} - -require() -{ - eval [ -n "\$$1" ] || fatal_error "Required option $1 not set" -} - # # Change to the directory containing this script # @@ -122,6 +71,11 @@ else Product="Shorewall6 Lite" fi +# +# Source common functions +# +. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; } + # # Parse the run line # diff --git a/Shorewall/install.sh b/Shorewall/install.sh index 38c43cf3f..7bce5032b 100755 --- a/Shorewall/install.sh +++ b/Shorewall/install.sh @@ -39,38 +39,6 @@ usage() # $1 = exit status exit $1 } -fatal_error() -{ - echo " ERROR: $@" >&2 - exit 1 -} - -split() { - local ifs - ifs=$IFS - IFS=: - set -- $1 - echo $* - IFS=$ifs -} - -qt() -{ - "$@" >/dev/null 2>&1 -} - -mywhich() { - local dir - - for dir in $(split $PATH); do - if [ -x $dir/$1 ]; then - return 0 - fi - done - - return 2 -} - run_install() { if ! install $*; then @@ -86,21 +54,11 @@ cant_autostart() echo "WARNING: Unable to configure $PRODUCT to start automatically at boot" >&2 } -delete_file() # $1 = file to delete -{ - rm -f $1 -} - install_file() # $1 = source $2 = target $3 = mode { run_install $T $OWNERSHIP -m $3 $1 ${2} } -require() -{ - eval [ -n "\$$1" ] || fatal_error "Required option $1 not set" -} - cd "$(dirname $0)" if [ -f shorewall.service ]; then @@ -111,6 +69,11 @@ else Product=Shorewall6 fi +# +# Source common functions +# +. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; } + # # Parse the run line #