Modify CLIs and libs to know where shorewallrc is.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-03-30 12:02:25 -07:00
parent 4c2cdd5a07
commit 15335f8615
12 changed files with 96 additions and 223 deletions

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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 [ <shorewallrc file> ]"
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

View File

@ -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)

View File

@ -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

View File

@ -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 [ <shorewallrc file> ]"
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

View File

@ -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"

View File

@ -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"

View File

@ -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 [ <shorewallrc file> ]"
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

View File

@ -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

View File

@ -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"