Many changes involved in getting a relocated installations to work

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-04-01 10:47:24 -07:00
parent e48e13012c
commit bb6e17fd3e
25 changed files with 80 additions and 83 deletions

View File

@ -113,7 +113,7 @@ for on in \
AUXINITSOURCE \
AUXINITFILE \
SYSTEMD \
SYSCONFILE \
SYSCONFFILE \
SYSCONFDIR \
ANNOTATED \
VARDIR
@ -122,6 +122,3 @@ do
done
cat shorewallrc

View File

@ -139,8 +139,8 @@ done
if [ $# -eq 0 ]; then
if [ -f ./shorewallrc ]; then
. ./shorewallrc
file=~/.shorewallrc
elif [ -f ./.shorewallrc ]; then
file=./shorewallrc
elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc || exit 1
file=~/.shorewallrc
elif [ -f /usr/share/shorewall/shorewallrc ]; then
@ -343,9 +343,9 @@ chmod 644 ${DESTDIR}${SHAREDIR}/shorewall/coreversion
if [ ${SHAREDIR} != /usr/share ]; then
for f in lib.*; do
if [ $BUILD != apple ]; then
eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}/${SHAREDIR}/$f
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SHAREDIR}/shorewall/$f
else
eval sed -i \'\' -e \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/$f
eval sed -i \'\' -e \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SHAREDIR}/shorewall/$f
fi
done
fi

View File

@ -42,6 +42,7 @@ if [ -z "$g_readrc" ]; then
g_sharedir="$SHAREDIR"
g_sbindir="$SBINDIR"
g_vardir="$VARDIR"
g_confdir="$CONFDIR"
g_readrc=1
fi

View File

@ -33,11 +33,13 @@ if [ -z "$g_readrc" ]; then
g_libexec="$LIBEXECDIR"
g_sharedir="$SHAREDIR"
g_sbindir="$SBINDIR"
g_confdir="$CONFDIR"
g_readrc=1
fi
. ${g_sharedir}/shorewall/lib.base
#
# Fatal Error
#

View File

@ -265,7 +265,7 @@ fi
#
if [ -n "$INITFILE" ]; then
install_file $INITSOURCE ${DESTDIR}${INITDIR}/$INITFILE 0544
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}${INITDIR}/$INITFILE
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${INITDIR}/$INITFILE
if [ -n "${AUXINITSOURCE}" ]; then
install_file $INITSOURCE ${DESTDIR}${INITDIR}/$AUXINITFILE 0544
@ -347,7 +347,7 @@ fi
cp ifupdown.sh ifupdown
d[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ifupdown
d[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ifupdown
mkdir -p ${DESTDIR}${LIBEXECDIR}/shorewall-init

View File

@ -360,7 +360,7 @@ if [ -n "$INITFILE" ]; then
;;
esac
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' "$initfile"
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' "$initfile"
echo "$Product init script installed in $initfile"
fi
@ -498,8 +498,8 @@ if [ -n "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PRODUCT} ]; then
fi
if [ ${SHAREDIR} != /usr/share ]; then
eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}/${SHAREDIR}/${PRODUCT}/lib.base
eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}/${SBINDIR}/$PRODUCT
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SHAREDIR}/${PRODUCT}/lib.base
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SBINDIR}/$PRODUCT
fi
if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then

View File

@ -54,10 +54,10 @@ my $family;
#
# Initilize the package-globals in the other modules
#
sub initialize_package_globals( $ ) {
Shorewall::Config::initialize($family);
sub initialize_package_globals( $$ ) {
Shorewall::Config::initialize($family, $_[1]);
Shorewall::Chains::initialize ($family, 1, $export );
Shorewall::Zones::initialize ($family, shift);
Shorewall::Zones::initialize ($family, $_[0]);
Shorewall::Nat::initialize;
Shorewall::Providers::initialize($family);
Shorewall::Tc::initialize($family);
@ -545,8 +545,8 @@ EOF
#
sub compiler {
my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview, $confess , $update , $annotate , $convert, $config_path ) =
( '', '', -1, '', 0, '', '', -1, 0, 0, 0, 0, , 0 , '');
my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview, $confess , $update , $annotate , $convert, $config_path, $shorewallrc ) =
( '', '', -1, '', 0, '', '', -1, 0, 0, 0, 0, , 0 , '' , '');
$export = 0;
$test = 0;
@ -584,6 +584,7 @@ sub compiler {
convert => { store => \$convert, validate=> \&validate_boolean } ,
annotate => { store => \$annotate, validate=> \&validate_boolean } ,
config_path => { store => \$config_path } ,
shorewallrc => { store => \$shorewallrc } ,
);
#
# P A R A M E T E R P R O C E S S I N G
@ -601,7 +602,7 @@ sub compiler {
#
# Now that we know the address family (IPv4/IPv6), we can initialize the other modules' globals
#
initialize_package_globals( $update );
initialize_package_globals( $update, $shorewallrc );
set_config_path( $config_path ) if $config_path;

View File

@ -439,7 +439,7 @@ my $ifstack;
#
our %shorewallrc;
sub process_shorewallrc();
sub process_shorewallrc($);
#
# Rather than initializing globals in an INIT block or during declaration,
# we initialize them in a function. This is done for two reasons:
@ -450,8 +450,8 @@ sub process_shorewallrc();
# 2. The compiler can run multiple times in the same process so it has to be
# able to re-initialize its dependent modules' state.
#
sub initialize( $ ) {
$family = shift;
sub initialize( $;$ ) {
( $family, my $shorewallrc ) = @_;
if ( $family == F_IPV4 ) {
( $product, $Product, $toolname, $toolNAME ) = qw( shorewall Shorewall iptables IPTABLES );
@ -759,21 +759,23 @@ sub initialize( $ ) {
CONFDIR => '/etc/',
);
process_shorewallrc;
if ( $shorewallrc ) {
process_shorewallrc( $shorewallrc );
$globals{SHAREDIRPL} = "$shorewallrc{SHAREDIR}/shorewall/";
$globals{SHAREDIRPL} = "$shorewallrc{SHAREDIR}/shorewall/";
if ( $family == F_IPV4 ) {
$globals{SHAREDIR} = "$shorewallrc{SHAREDIR}/shorewall";
$globals{CONFDIR} = "$shorewallrc{CONFDIR}/shorewall";
$globals{PRODUCT} = 'shorewall';
$config{IPTABLES} = undef;
$validlevels{ULOG} = 'ULOG';
} else {
$globals{SHAREDIR} = "$shorewallrc{SHAREDIR}/shorewall6";
$globals{CONFDIR} = "$shorewallrc{CONFDIR}/shorewall6";
$globals{PRODUCT} = 'shorewall6';
$config{IP6TABLES} = undef;
if ( $family == F_IPV4 ) {
$globals{SHAREDIR} = "$shorewallrc{SHAREDIR}/shorewall";
$globals{CONFDIR} = "$shorewallrc{CONFDIR}/shorewall";
$globals{PRODUCT} = 'shorewall';
$config{IPTABLES} = undef;
$validlevels{ULOG} = 'ULOG';
} else {
$globals{SHAREDIR} = "$shorewallrc{SHAREDIR}/shorewall6";
$globals{CONFDIR} = "$shorewallrc{CONFDIR}/shorewall6";
$globals{PRODUCT} = 'shorewall6';
$config{IP6TABLES} = undef;
}
}
}
@ -2276,12 +2278,12 @@ sub read_a_line1() {
}
}
sub process_shorewallrc() {
my $home = $ENV{HOME} || `echo ~`;
sub process_shorewallrc( $ ) {
my $shorewallrc = shift;
$shorewallrc{PRODUCT} = $family == F_IPV4 ? 'shorewall' : 'shorewall6';
if ( $home && open_file "$home/.shorewallrc" ) {
if ( open_file $shorewallrc ) {
while ( read_a_line1 ) {
if ( $currentline =~ /^([a-zA-Z]\w*)=(.*)$/ ) {
my ($var, $val) = ($1, $2);
@ -2292,6 +2294,8 @@ sub process_shorewallrc() {
fatal_error "Unrecognized shorewallrc entry";
}
}
} else {
fatal_error "Failed to open $shorewallrc: $!";
}
}
@ -3469,7 +3473,7 @@ sub process_shorewall_conf( $$ ) {
#
for ( values %config ) {
if ( supplied $_ ) {
expand_variables( $_ ) unless /^'(.+)'$/;
expand_variables( $_, 1) unless /^'(.+)'$/;
}
}
}

View File

@ -65,6 +65,7 @@ sub usage( $ ) {
[ --annotate ]
[ --update ]
[ --convert ]
[ --shorewallrc ]
[ --config_path=<path-list> ]
';
@ -91,6 +92,7 @@ my $annotate = 0;
my $update = 0;
my $convert = 0;
my $config_path = '';
my $shorewallrc = '';
Getopt::Long::Configure ('bundling');
@ -122,6 +124,7 @@ my $result = GetOptions('h' => \$help,
'update' => \$update,
'convert' => \$convert,
'config_path=s' => \$config_path,
'shorewallrc=s' => \$shorewallrc,
);
usage(1) unless $result && @ARGV < 2;
@ -144,4 +147,5 @@ compiler( script => $ARGV[0] || '',
convert => $convert,
annotate => $annotate,
config_path => $config_path,
shorewallrc => $shorewallrc
);

View File

@ -53,7 +53,7 @@ TCP_FLAGS_LOG_LEVEL=info
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
IPTABLES=

View File

@ -64,7 +64,7 @@ TCP_FLAGS_LOG_LEVEL=info
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
IPTABLES=

View File

@ -62,7 +62,7 @@ TCP_FLAGS_LOG_LEVEL=info
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
IPTABLES=

View File

@ -65,7 +65,7 @@ TCP_FLAGS_LOG_LEVEL=info
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
IPTABLES=

View File

@ -53,7 +53,7 @@ TCP_FLAGS_LOG_LEVEL=info
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH="/etc/shorewall:/usr/share/shorewall"
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
IPTABLES=

View File

@ -10,4 +10,4 @@
# /usr/share/shorewall/configfiles/. This prevents 'compile -e'
# from trying to use configuration information from /etc/shorewall.
CONFIG_PATH=${CONFDIR}:/usr/share/shorewall
CONFIG_PATH=${CONFDIR}:${SHAREDIR}/shorewall

View File

@ -320,6 +320,7 @@ if [ -z "${DESTDIR}" -a $PRODUCT = shorewall -a ! -f ${SHAREDIR}/$PRODUCT/coreve
fi
install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0755
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SBINDIR}/${PRODUCT}
echo "$PRODUCT control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
#
@ -327,7 +328,7 @@ echo "$PRODUCT control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
#
if [ -n "$INITFILE" ]; then
install_file $INITSOURCE ${DESTDIR}${INITDIR}/$INITFILE 0544
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}${INITDIR}/$INITFILE
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${INITDIR}/$INITFILE
if [ -n "${AUXINITSOURCE}" ]; then
install_file $INITSOURCE ${DESTDIR}${INITDIR}/$INITFILE 0544
@ -993,7 +994,7 @@ if [ $PRODUCT = shorewall6 ]; then
# Symbolically link 'functions' to lib.base
#
ln -sf lib.base ${DESTDIR}${SHAREDIR}/$PRODUCT/functions
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/|${SHAREDIR}/|\' ${DESTDIR}/${SHAREDIR}/${PRODUCT}/lib.base
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SHAREDIR}/${PRODUCT}/lib.base
fi
if [ -d Perl ]; then

View File

@ -31,9 +31,12 @@
#
get_config() {
local prog
local confdir
ensure_config_path
if [ "$1" = Yes ]; then
params=$(find_file params)
@ -46,7 +49,10 @@ get_config() {
if [ -f $config ]; then
if [ -r $config ]; then
confdir=${CONFDIR}
CONFDIR=${g_confdir}
. $config
CONFDIR=${confdir}
else
echo "Cannot read $config! (Hint: Are you root?)" >&2
exit 1
@ -395,7 +401,7 @@ compiler() {
[ "$1" = nolock ] && shift;
shift
options="--verbose=$VERBOSITY --family=$g_family --config_path=$CONFIG_PATH"
options="--verbose=$VERBOSITY --family=$g_family --config_path=$CONFIG_PATH --shorewallrc=${g_sharedir}/shorewall/shorewallrc"
[ -n "$STARTUP_LOG" ] && options="$options --log=$STARTUP_LOG"
[ -n "$LOG_VERBOSITY" ] && options="$options --log_verbosity=$LOG_VERBOSITY";
[ -n "$g_export" ] && options="$options --export"

View File

@ -36,6 +36,7 @@ g_libexec="$LIBEXECDIR"
g_sharedir="$SHAREDIR"
g_sbindir="$SBINDIR"
g_perllib="$PERLLIBDIR"
g_confdir="$CONFDIR"
g_readrc=1
. $g_sharedir/shorewall/lib.cli

View File

@ -27,30 +27,16 @@
################################################################################################
g_program=shorewall6-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
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"
g_sbindir="$SBINDIR"
g_perllib="$PERLLIBDIR"
g_confdir="$CONFDIR"
g_readrc=1
. $g_sharedir/shorewall/lib.cli

View File

@ -52,7 +52,7 @@ TCP_FLAGS_LOG_LEVEL=info
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall6:/usr/share/shorewall6:/usr/share/shorewall
CONFIG_PATH=${CONFDIR}/shorewall6:${SHAREDIR}/shorewall6:${SHAREDIR}/shorewall
IP6TABLES=

View File

@ -52,7 +52,7 @@ TCP_FLAGS_LOG_LEVEL=info
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall6:/usr/share/shorewall6:/usr/share/shorewall
CONFIG_PATH=${CONFDIR}/shorewall6:${SHAREDIR}/shorewall6:${SHAREDIR}/shorewall
IP6TABLES=

View File

@ -52,7 +52,7 @@ TCP_FLAGS_LOG_LEVEL=info
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall6:/usr/share/shorewall6:/usr/share/shorewall
CONFIG_PATH=${CONFDIR}/shorewall6:${SHAREDIR}/shorewall6:${SHAREDIR}/shorewall
IP6TABLES=

View File

@ -52,7 +52,7 @@ TCP_FLAGS_LOG_LEVEL=info
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall6:/usr/share/shorewall6:/usr/share/shorewall
CONFIG_PATH=${CONFDIR}/shorewall6:${SHAREDIR}/shorewall6:${SHAREDIR}/shorewall
IP6TABLES=

View File

@ -52,7 +52,7 @@ TCP_FLAGS_LOG_LEVEL=info
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH="/etc/shorewall6:/usr/share/shorewall6:/usr/share/shorewall"
CONFIG_PATH="${CONFDIR}/shorewall6:/usr/share/shorewall6:${SHAREDIR}/shorewall"
IP6TABLES=

View File

@ -27,22 +27,16 @@
################################################################################################
g_program=shorewall6
if [ -f ~/.shorewallrc ]; then
. ~/.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"
g_sbindir="$SBINDIR"
g_perllib="$PERLLIBDIR"
g_confdir="$CONFDIR"
g_readrc=1
. $g_sharedir/shorewall/lib.cli