diff --git a/Shorewall-core/install.sh b/Shorewall-core/install.sh index d7b544647..67984e659 100755 --- a/Shorewall-core/install.sh +++ b/Shorewall-core/install.sh @@ -137,21 +137,12 @@ done # Read the RC file # if [ $# -eq 0 ]; then - if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 - file=./.shorewallrc - elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 - file=/root/.shorewallrc - elif [ -r /.shorewallrc ]; then - . /.shorewallrc || exit 1 - file =/.shorewallrc - elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 - file=~/.shorewallrc - elif - -f ${SHOREWALLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 - file=${SHOREWALLRC_HOME}/.shorewallrc + if [ -f ~/.shorewallrc ]; then + . ~/.shorewallrc + elif [ -f /usr/share/shorewall/shorewallrc ]; then + . /usr/share/shorewall/shorewallrc + else + fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi elif [ $# -eq 1 ]; then file=$1 @@ -328,8 +319,16 @@ chmod 644 ${DESTDIR}${SHAREDIR}/shorewall/coreversion cp $file ${DESTDIR}${SHAREDIR}/shorewall/shorewallrc -if [ -z "${DESTDIR}" -a -n ${HOME} ]; then - [ -f ${HOME}/.shorewallrc ] || cp $file ${HOME}/.shorewallrc +[ -z "${DESTDIR}" ] && [ ! -f ~/.shorewallrc ] && cp ${SHAREDIR}/shorewall/shorewallrc ~/.shorewallrc + +if [ ${SHAREDIR} != /usr/share ]; then + for f in lib.*; do + if [ $BUILD != apple ]; then + eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}/${SHAREDIR}/$f + else + eval sed -i \'\' -e \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/$f + fi + done fi # # Report Success diff --git a/Shorewall-core/lib.base b/Shorewall-core/lib.base index 568ffe07b..153ee8dd7 100644 --- a/Shorewall-core/lib.base +++ b/Shorewall-core/lib.base @@ -33,23 +33,10 @@ SHOREWALL_CAPVERSION=40502 [ -n "${g_program:=shorewall}" ] if [ -z "$g_readrc" ]; then - - if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 - elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 - elif [ -r /.shorewallrc ]; then - . /root/.shorewallrc || exit 1 - elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 - elif - -f ${SHOREWALLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 - else - SHAREDIR=/usr/share - CONFDIR=/etc - SBINDIR=/sbin - LIBEXECDIR=/usr/share - fi + # + # This is modified by the installer when ${SHAREDIR} <> /usr/share + # + . /usr/share/shorewall/shorewallrc g_libexec="$LIBEXECDIR" g_sharedir="$SHAREDIR" diff --git a/Shorewall-core/lib.cli b/Shorewall-core/lib.cli index 2d6366e76..62215723b 100644 --- a/Shorewall-core/lib.cli +++ b/Shorewall-core/lib.cli @@ -25,22 +25,10 @@ # if [ -z "$g_readrc" ]; then - if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 - elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 - elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 - elif [ -r /.shorewallrc ]; then - . /root/.shorewallrc || exit 1 - elif - -f ${SHOREWALLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 - else - SHAREDIR=/usr/share - CONFDIR=${CONFDIR} - SBINDIR=/sbin - LIBEXECDIR=/usr/share - fi + # + # This is modified by the installer when ${SHAREDIR} <> /usr/share + # + . /usr/share/shorewall/shorewallrc g_libexec="$LIBEXECDIR" g_sharedir="$SHAREDIR" diff --git a/Shorewall-core/uninstall.sh b/Shorewall-core/uninstall.sh index 6fc6af188..0f1e4eebd 100755 --- a/Shorewall-core/uninstall.sh +++ b/Shorewall-core/uninstall.sh @@ -31,7 +31,7 @@ VERSION=xxx #The Build script inserts the actual version usage() # $1 = exit status { ME=$(basename $0) - echo "usage: $ME" + echo "usage: $ME [ ]" exit $1 } @@ -60,20 +60,23 @@ remove_file() # $1 = file to restore fi } -if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 -elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 -elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif [ -r /.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif - -f ${SHOREAWLLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 +if [ $# -eq 0 ]; then + file=/usr/share/shorewall/shorewallrc +elif [ $# -eq 1 ]; then + file=$1 else - SHAREDIR=/usr/share + usage 1 fi +if [ -f "$file" ]; then + . "$file" +else + echo "File $file not found" >&2 + exit 1 +fi + +. $file || exit 1 + if [ -f ${SHAREDIR}/shorewall/coreversion ]; then INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall/coreversion)" if [ "$INSTALLED_VERSION" != "$VERSION" ]; then diff --git a/Shorewall-init/install.sh b/Shorewall-init/install.sh index 5679e5b2d..3e14a0b01 100755 --- a/Shorewall-init/install.sh +++ b/Shorewall-init/install.sh @@ -136,21 +136,9 @@ if [ $# -eq 0 ]; then # # Load packager's settings if any # - if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 - file=./.shorewallrc - elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 - file=/root/.shorewallrc - elif [ -r /.shorewallrc ]; then - . /.shorewallrc || exit 1 - file =/.shorewallrc - elif [ -f ~/.shorewallrc ]; then + if [ -f ~/.shorewallrc ]; then . ~/.shorewallrc || exit 1 file=~/.shorewallrc - elif - -f ${SHOREWALLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 - file=${SHOREWALLRC_HOME}/.shorewallrc else fatal_error "No configuration file specified and ~/.shorewallrc not found" fi @@ -430,6 +418,8 @@ else fi fi +[ -z "${DESTDIR}" ] && [ ! -f ~/.shorewallrc ] && cp ${SHAREDIR}/shorewall/shorewallrc . + if [ -f ${DESTDIR}/etc/ppp ]; then case $HOST in debian|suse) diff --git a/Shorewall-init/shorewall-init b/Shorewall-init/shorewall-init index 5ea9a304e..1be5d0804 100644 --- a/Shorewall-init/shorewall-init +++ b/Shorewall-init/shorewall-init @@ -23,21 +23,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # ######################################################################################### -if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 -elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 -elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif [ -r /.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif - -f ${SHOREWALLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 -else - VARDIR=/var/lib - LIBEXECDIR=/usr/share - SYSCONFDIR=/etc/sysconfig -fi +# +# This is modified by the installer when ${SHAREDIR} <> /usr/share +# +. /usr/share/shorewall/shorewallrc # check if shorewall-init is configured or not if [ -f "$SYSCONFDIR/shorewall-init" ]; then diff --git a/Shorewall-init/uninstall.sh b/Shorewall-init/uninstall.sh index 78ff5e754..222f0ddb1 100755 --- a/Shorewall-init/uninstall.sh +++ b/Shorewall-init/uninstall.sh @@ -31,7 +31,7 @@ VERSION=xxx #The Build script inserts the actual version usage() # $1 = exit status { ME=$(basename $0) - echo "usage: $ME" + echo "usage: $ME [ ]" exit $1 } @@ -69,37 +69,23 @@ remove_file() # $1 = file to restore fi } -if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 -elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 -elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif [ -r /.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif - -f ${SHOREAWLLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 +if [ $# -eq 0 ]; then + file=/usr/share/shorewall/shorewallrc +elif [ $# -eq 1 ]; then + file=$1 else - [ -n "${LIBEXEC:=/usr/share}" ] - [ -n "${PERLLIB:=/usr/share/shorewall}" ] - [ -n "${CONFDIR:=/etc}" ] - - if [ -z "$SYSCONFDIR" ]; then - if [ -d /etc/default ]; then - SYSCONFDIR=/etc/default - else - SYSCONFDIR=/etc/sysconfig - fi - fi - - [ -n "${SBINDIR:=/sbin}" ] - [ -n "${SHAREDIR:=/usr/share}" ] - [ -n "${VARDIR:=/var/lib}" ] - [ -n "${INITFILE:=shorewall}" ] - [ -n "${INITDIR:=/etc/init.d}" ] - [ -n "${MANDIR:=/usr/share/man}" ] + usage 1 fi +if [ -f "$file" ]; then + . "$file" +else + echo "File $file not found" >&2 + exit 1 +fi + +. $file || exit 1 + if [ -f ${SHAREDIR}/shorewall-init/version ]; then INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall-init/version)" if [ "$INSTALLED_VERSION" != "$VERSION" ]; then diff --git a/Shorewall-lite/install.sh b/Shorewall-lite/install.sh index d7d386024..a4b901763 100755 --- a/Shorewall-lite/install.sh +++ b/Shorewall-lite/install.sh @@ -146,26 +146,12 @@ done # Read the RC file # if [ $# -eq 0 ]; then - # - # Load packager's settings if any - # - if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 - file=./.shorewallrc - elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 - file=/root/.shorewallrc - elif [ -r /.shorewallrc ]; then - . /.shorewallrc || exit 1 - file =/.shorewallrc - elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 - file=~/.shorewallrc - elif - -f ${SHOREWALLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 - file=${SHOREWALLRC_HOME}/.shorewallrc + if [ -f ~/.shorewallrc ]; then + . ~/.shorewallrc + elif [ -f /usr/share/shorewall/shorewallrc ]; then + . /usr/share/shorewall/shorewallrc else - fatal_error "No configuration file specified and ~/.shorewallrc not found" + fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi elif [ $# -eq 1 ]; then file=$1 @@ -503,6 +489,11 @@ if [ -n "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PRODUCT} ]; then echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}" fi +if [ ${SHAREDIR} != /usr/share ]; then + [ $PRODUCT = shorewall ] && eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}/${SHAREDIR}/lib.base + sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}/${SBINDIR}/$PRODUCT +fi + if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then if mywhich update-rc.d ; then echo "$PRODUCT will start automatically at boot" diff --git a/Shorewall-lite/shorewall-lite b/Shorewall-lite/shorewall-lite index 7b824a320..779b8fbc1 100755 --- a/Shorewall-lite/shorewall-lite +++ b/Shorewall-lite/shorewall-lite @@ -27,24 +27,10 @@ ################################################################################################ g_program=shorewall-lite -if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 -elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 -elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif [ -r /.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif - -f ${SHOREWALLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 -else - SHAREDIR=/usr/share - CONFDIR=/etc - SBINDIR=/sbin - VARDIR=/var/lib - LIBEXECDIR=/usr/share - -fi +# +# This is modified by the installer when ${SHAREDIR} <> /usr/share +# +. /usr/share/shorewall/shorewallrc g_libexec="$LIBEXECDIR" g_sharedir="$SHAREDIR" diff --git a/Shorewall-lite/uninstall.sh b/Shorewall-lite/uninstall.sh index 8454ce55c..615821e76 100755 --- a/Shorewall-lite/uninstall.sh +++ b/Shorewall-lite/uninstall.sh @@ -31,7 +31,7 @@ VERSION=xxx #The Build script inserts the actual version usage() # $1 = exit status { ME=$(basename $0) - echo "usage: $ME" + echo "usage: $ME [ ]" exit $1 } @@ -69,35 +69,19 @@ remove_file() # $1 = file to restore fi } -if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 -elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 -elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif [ -r /.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif - -f ${SHOREAWLLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 +if [ $# -eq 0 ]; then + file=/usr/share/shorewall/shorewallrc +elif [ $# -eq 1 ]; then + file=$1 else - [ -n "${LIBEXEC:=/usr/share}" ] - [ -n "${PERLLIB:=/usr/share/shorewall}" ] - [ -n "${CONFDIR:=/etc}" ] - - if [ -z "$SYSCONFDIR" ]; then - if [ -d /etc/default ]; then - SYSCONFDIR=/etc/default - else - SYSCONFDIR=/etc/sysconfig - fi - fi + usage 1 +fi - [ -n "${SBINDIR:=/sbin}" ] - [ -n "${SHAREDIR:=/usr/share}" ] - [ -n "${VARDIR:=/var/lib}" ] - [ -n "${INITFILE:=shorewall}" ] - [ -n "${INITDIR:=/etc/init.d}" ] - [ -n "${MANDIR:=/usr/share/man}" ] +if [ -f "$file" ]; then + . "$file" +else + echo "File $file not found" >&2 + exit 1 fi if [ -f ${SHAREDIR}/shorewall-lite/version ]; then diff --git a/Shorewall/install.sh b/Shorewall/install.sh index e56a2b5e1..7dc111d77 100755 --- a/Shorewall/install.sh +++ b/Shorewall/install.sh @@ -105,8 +105,6 @@ cd "$(dirname $0)" # # Load packager's settings if any # -[ -f ../shorewall-pkg.config ] && . ../shorewall-pkg.config - if [ -f shorewall ]; then PRODUCT=shorewall Product=Shorewall @@ -170,26 +168,12 @@ done # Read the RC file # if [ $# -eq 0 ]; then - # - # Load packager's settings if any - # - if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 - file=./.shorewallrc - elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 - file=/root/.shorewallrc - elif [ -r /.shorewallrc ]; then - . /.shorewallrc || exit 1 - file =/.shorewallrc - elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 - file=~/.shorewallrc - elif - -f ${SHOREWALLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 - file=${SHOREWALLRC_HOME}/.shorewallrc + if [ -f ~/.shorewallrc ]; then + . ~/.shorewallrc + elif [ -f /usr/share/shorewall/shorewallrc ]; then + . /usr/share/shorewall/shorewallrc else - fatal_error "No configuration file specified and .shorewallrc not found" + fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fi elif [ $# -eq 1 ]; then file=$1 diff --git a/Shorewall/shorewall b/Shorewall/shorewall index b7bc7b810..5492a42d1 100755 --- a/Shorewall/shorewall +++ b/Shorewall/shorewall @@ -27,24 +27,10 @@ ################################################################################################ g_program=shorewall -if [ -f ./.shorewallrc ]; then - . ./.shorewallrc || exit 1 -elif [ -f ~/.shorewallrc ]; then - . ~/.shorewallrc || exit 1 -elif [ -r /root/.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif [ -r /.shorewallrc ]; then - . /root/.shorewallrc || exit 1 -elif - -f ${SHOREAWLLRC_HOME}/.shorewallrc; then - . ${SHOREWALLRC_HOME}/.shorewallrc || exit 1 -else - SHAREDIR=/usr/share - CONFDIR=/etc - SBINDIR=/sbin - VARDIR=/var/lib - LIBEXECDIR=/usr/share - PERLLIBDIR=/usr/share/shorewall -fi +# +# This is modified by the installer when ${SHAREDIR} <> /usr/share +# +. /usr/share/shorewall/shorewallrc g_libexec="$LIBEXECDIR" g_sharedir="$SHAREDIR"