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 # Read the RC file
# #
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [ -f ./.shorewallrc ]; then if [ -f ~/.shorewallrc ]; then
. ./.shorewallrc || exit 1 . ~/.shorewallrc
file=./.shorewallrc elif [ -f /usr/share/shorewall/shorewallrc ]; then
elif [ -r /root/.shorewallrc ]; then . /usr/share/shorewall/shorewallrc
. /root/.shorewallrc || exit 1 else
file=/root/.shorewallrc fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
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
fi fi
elif [ $# -eq 1 ]; then elif [ $# -eq 1 ]; then
file=$1 file=$1
@ -328,8 +319,16 @@ chmod 644 ${DESTDIR}${SHAREDIR}/shorewall/coreversion
cp $file ${DESTDIR}${SHAREDIR}/shorewall/shorewallrc cp $file ${DESTDIR}${SHAREDIR}/shorewall/shorewallrc
if [ -z "${DESTDIR}" -a -n ${HOME} ]; then [ -z "${DESTDIR}" ] && [ ! -f ~/.shorewallrc ] && cp ${SHAREDIR}/shorewall/shorewallrc ~/.shorewallrc
[ -f ${HOME}/.shorewallrc ] || cp $file ${HOME}/.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 fi
# #
# Report Success # Report Success

View File

@ -33,23 +33,10 @@ SHOREWALL_CAPVERSION=40502
[ -n "${g_program:=shorewall}" ] [ -n "${g_program:=shorewall}" ]
if [ -z "$g_readrc" ]; then if [ -z "$g_readrc" ]; then
#
if [ -f ./.shorewallrc ]; then # This is modified by the installer when ${SHAREDIR} <> /usr/share
. ./.shorewallrc || exit 1 #
elif [ -r /root/.shorewallrc ]; then . /usr/share/shorewall/shorewallrc
. /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
g_libexec="$LIBEXECDIR" g_libexec="$LIBEXECDIR"
g_sharedir="$SHAREDIR" g_sharedir="$SHAREDIR"

View File

@ -25,22 +25,10 @@
# #
if [ -z "$g_readrc" ]; then if [ -z "$g_readrc" ]; then
if [ -f ./.shorewallrc ]; then #
. ./.shorewallrc || exit 1 # This is modified by the installer when ${SHAREDIR} <> /usr/share
elif [ -f ~/.shorewallrc ]; then #
. ~/.shorewallrc || exit 1 . /usr/share/shorewall/shorewallrc
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
g_libexec="$LIBEXECDIR" g_libexec="$LIBEXECDIR"
g_sharedir="$SHAREDIR" g_sharedir="$SHAREDIR"

View File

@ -31,7 +31,7 @@ VERSION=xxx #The Build script inserts the actual version
usage() # $1 = exit status usage() # $1 = exit status
{ {
ME=$(basename $0) ME=$(basename $0)
echo "usage: $ME" echo "usage: $ME [ <shorewallrc file> ]"
exit $1 exit $1
} }
@ -60,20 +60,23 @@ remove_file() # $1 = file to restore
fi fi
} }
if [ -f ./.shorewallrc ]; then if [ $# -eq 0 ]; then
. ./.shorewallrc || exit 1 file=/usr/share/shorewall/shorewallrc
elif [ -f ~/.shorewallrc ]; then elif [ $# -eq 1 ]; then
. ~/.shorewallrc || exit 1 file=$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 else
SHAREDIR=/usr/share usage 1
fi 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 if [ -f ${SHAREDIR}/shorewall/coreversion ]; then
INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall/coreversion)" INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall/coreversion)"
if [ "$INSTALLED_VERSION" != "$VERSION" ]; then if [ "$INSTALLED_VERSION" != "$VERSION" ]; then

View File

@ -136,21 +136,9 @@ if [ $# -eq 0 ]; then
# #
# Load packager's settings if any # Load packager's settings if any
# #
if [ -f ./.shorewallrc ]; 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 . ~/.shorewallrc || exit 1
file=~/.shorewallrc file=~/.shorewallrc
elif - -f ${SHOREWALLRC_HOME}/.shorewallrc; then
. ${SHOREWALLRC_HOME}/.shorewallrc || exit 1
file=${SHOREWALLRC_HOME}/.shorewallrc
else else
fatal_error "No configuration file specified and ~/.shorewallrc not found" fatal_error "No configuration file specified and ~/.shorewallrc not found"
fi fi
@ -430,6 +418,8 @@ else
fi fi
fi fi
[ -z "${DESTDIR}" ] && [ ! -f ~/.shorewallrc ] && cp ${SHAREDIR}/shorewall/shorewallrc .
if [ -f ${DESTDIR}/etc/ppp ]; then if [ -f ${DESTDIR}/etc/ppp ]; then
case $HOST in case $HOST in
debian|suse) debian|suse)

View File

@ -23,21 +23,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
######################################################################################### #########################################################################################
if [ -f ./.shorewallrc ]; then #
. ./.shorewallrc || exit 1 # This is modified by the installer when ${SHAREDIR} <> /usr/share
elif [ -f ~/.shorewallrc ]; then #
. ~/.shorewallrc || exit 1 . /usr/share/shorewall/shorewallrc
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
# check if shorewall-init is configured or not # check if shorewall-init is configured or not
if [ -f "$SYSCONFDIR/shorewall-init" ]; then 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 usage() # $1 = exit status
{ {
ME=$(basename $0) ME=$(basename $0)
echo "usage: $ME" echo "usage: $ME [ <shorewallrc file> ]"
exit $1 exit $1
} }
@ -69,37 +69,23 @@ remove_file() # $1 = file to restore
fi fi
} }
if [ -f ./.shorewallrc ]; then if [ $# -eq 0 ]; then
. ./.shorewallrc || exit 1 file=/usr/share/shorewall/shorewallrc
elif [ -f ~/.shorewallrc ]; then elif [ $# -eq 1 ]; then
. ~/.shorewallrc || exit 1 file=$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 else
[ -n "${LIBEXEC:=/usr/share}" ] usage 1
[ -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}" ]
fi 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 if [ -f ${SHAREDIR}/shorewall-init/version ]; then
INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall-init/version)" INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall-init/version)"
if [ "$INSTALLED_VERSION" != "$VERSION" ]; then if [ "$INSTALLED_VERSION" != "$VERSION" ]; then

View File

@ -146,26 +146,12 @@ done
# Read the RC file # Read the RC file
# #
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
# if [ -f ~/.shorewallrc ]; then
# Load packager's settings if any . ~/.shorewallrc
# elif [ -f /usr/share/shorewall/shorewallrc ]; then
if [ -f ./.shorewallrc ]; then . /usr/share/shorewall/shorewallrc
. ./.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
else 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 fi
elif [ $# -eq 1 ]; then elif [ $# -eq 1 ]; then
file=$1 file=$1
@ -503,6 +489,11 @@ if [ -n "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PRODUCT} ]; then
echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}" echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
fi 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 [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
if mywhich update-rc.d ; then if mywhich update-rc.d ; then
echo "$PRODUCT will start automatically at boot" echo "$PRODUCT will start automatically at boot"

View File

@ -27,24 +27,10 @@
################################################################################################ ################################################################################################
g_program=shorewall-lite g_program=shorewall-lite
if [ -f ./.shorewallrc ]; then #
. ./.shorewallrc || exit 1 # This is modified by the installer when ${SHAREDIR} <> /usr/share
elif [ -f ~/.shorewallrc ]; then #
. ~/.shorewallrc || exit 1 . /usr/share/shorewall/shorewallrc
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
g_libexec="$LIBEXECDIR" g_libexec="$LIBEXECDIR"
g_sharedir="$SHAREDIR" g_sharedir="$SHAREDIR"

View File

@ -31,7 +31,7 @@ VERSION=xxx #The Build script inserts the actual version
usage() # $1 = exit status usage() # $1 = exit status
{ {
ME=$(basename $0) ME=$(basename $0)
echo "usage: $ME" echo "usage: $ME [ <shorewallrc file> ]"
exit $1 exit $1
} }
@ -69,35 +69,19 @@ remove_file() # $1 = file to restore
fi fi
} }
if [ -f ./.shorewallrc ]; then if [ $# -eq 0 ]; then
. ./.shorewallrc || exit 1 file=/usr/share/shorewall/shorewallrc
elif [ -f ~/.shorewallrc ]; then elif [ $# -eq 1 ]; then
. ~/.shorewallrc || exit 1 file=$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 else
[ -n "${LIBEXEC:=/usr/share}" ] usage 1
[ -n "${PERLLIB:=/usr/share/shorewall}" ] fi
[ -n "${CONFDIR:=/etc}" ]
if [ -z "$SYSCONFDIR" ]; then
if [ -d /etc/default ]; then
SYSCONFDIR=/etc/default
else
SYSCONFDIR=/etc/sysconfig
fi
fi
[ -n "${SBINDIR:=/sbin}" ] if [ -f "$file" ]; then
[ -n "${SHAREDIR:=/usr/share}" ] . "$file"
[ -n "${VARDIR:=/var/lib}" ] else
[ -n "${INITFILE:=shorewall}" ] echo "File $file not found" >&2
[ -n "${INITDIR:=/etc/init.d}" ] exit 1
[ -n "${MANDIR:=/usr/share/man}" ]
fi fi
if [ -f ${SHAREDIR}/shorewall-lite/version ]; then if [ -f ${SHAREDIR}/shorewall-lite/version ]; then

View File

@ -105,8 +105,6 @@ cd "$(dirname $0)"
# #
# Load packager's settings if any # Load packager's settings if any
# #
[ -f ../shorewall-pkg.config ] && . ../shorewall-pkg.config
if [ -f shorewall ]; then if [ -f shorewall ]; then
PRODUCT=shorewall PRODUCT=shorewall
Product=Shorewall Product=Shorewall
@ -170,26 +168,12 @@ done
# Read the RC file # Read the RC file
# #
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
# if [ -f ~/.shorewallrc ]; then
# Load packager's settings if any . ~/.shorewallrc
# elif [ -f /usr/share/shorewall/shorewallrc ]; then
if [ -f ./.shorewallrc ]; then . /usr/share/shorewall/shorewallrc
. ./.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
else 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 fi
elif [ $# -eq 1 ]; then elif [ $# -eq 1 ]; then
file=$1 file=$1

View File

@ -27,24 +27,10 @@
################################################################################################ ################################################################################################
g_program=shorewall g_program=shorewall
if [ -f ./.shorewallrc ]; then #
. ./.shorewallrc || exit 1 # This is modified by the installer when ${SHAREDIR} <> /usr/share
elif [ -f ~/.shorewallrc ]; then #
. ~/.shorewallrc || exit 1 . /usr/share/shorewall/shorewallrc
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
g_libexec="$LIBEXECDIR" g_libexec="$LIBEXECDIR"
g_sharedir="$SHAREDIR" g_sharedir="$SHAREDIR"