mirror of
https://gitlab.com/shorewall/code.git
synced 2025-02-22 20:51:15 +01:00
Make all references to directories indirect
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@4034 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
6f073f6cfd
commit
7c64464b66
@ -88,6 +88,10 @@
|
|||||||
#
|
#
|
||||||
# Fatal Error
|
# Fatal Error
|
||||||
#
|
#
|
||||||
|
SHAREDIR=/usr/share/shorewall
|
||||||
|
VARDIR=/var/lib/shorewall
|
||||||
|
CONFDIR=/etc/shorewall
|
||||||
|
|
||||||
fatal_error() # $@ = Message
|
fatal_error() # $@ = Message
|
||||||
{
|
{
|
||||||
echo " $@" >&2
|
echo " $@" >&2
|
||||||
@ -384,7 +388,7 @@ logwatch() # $1 = timeout -- if negative, prompt each time that
|
|||||||
#
|
#
|
||||||
save_config() {
|
save_config() {
|
||||||
if shorewall_is_started ; then
|
if shorewall_is_started ; then
|
||||||
[ -d /var/lib/shorewall ] || mkdir -p /var/lib/shorewall
|
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||||
|
|
||||||
if [ -f $RESTOREPATH -a ! -x $RESTOREPATH ]; then
|
if [ -f $RESTOREPATH -a ! -x $RESTOREPATH ]; then
|
||||||
echo " ERROR: $RESTOREPATH exists and is not a saved Shorewall configuration"
|
echo " ERROR: $RESTOREPATH exists and is not a saved Shorewall configuration"
|
||||||
@ -394,12 +398,12 @@ save_config() {
|
|||||||
echo " ERROR: Reserved file name: $RESTOREFILE"
|
echo " ERROR: Reserved file name: $RESTOREFILE"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if $IPTABLES -L dynamic -n > /var/lib/shorewall/save; then
|
if $IPTABLES -L dynamic -n > ${VARDIR}/save; then
|
||||||
echo " Dynamic Rules Saved"
|
echo " Dynamic Rules Saved"
|
||||||
if [ -f /var/lib/shorewall/.restore ]; then
|
if [ -f ${VARDIR}/.restore ]; then
|
||||||
if iptables-save | iptablesbug > /var/lib/shorewall/restore-$$; then
|
if iptables-save | iptablesbug > ${VARDIR}/restore-$$; then
|
||||||
cp -f /var/lib/shorewall/.restore $RESTOREPATH
|
cp -f ${VARDIR}/.restore $RESTOREPATH
|
||||||
mv -f /var/lib/shorewall/restore-$$ ${RESTOREPATH}-iptables
|
mv -f ${VARDIR}/restore-$$ ${RESTOREPATH}-iptables
|
||||||
chmod +x $RESTOREPATH
|
chmod +x $RESTOREPATH
|
||||||
echo " Currently-running Configuration Saved to $RESTOREPATH"
|
echo " Currently-running Configuration Saved to $RESTOREPATH"
|
||||||
|
|
||||||
@ -409,16 +413,16 @@ save_config() {
|
|||||||
[Yy][Ee][Ss])
|
[Yy][Ee][Ss])
|
||||||
RESTOREPATH=${RESTOREPATH}-ipsets
|
RESTOREPATH=${RESTOREPATH}-ipsets
|
||||||
|
|
||||||
f=/var/lib/shorewall/restore-$$
|
f=${VARDIR}/restore-$$
|
||||||
|
|
||||||
echo "#!/bin/sh" > $f
|
echo "#!/bin/sh" > $f
|
||||||
echo "#This ipset restore file generated $(date) by Shorewall $version" >> $f
|
echo "#This ipset restore file generated $(date) by Shorewall $version" >> $f
|
||||||
echo >> $f
|
echo >> $f
|
||||||
echo ". /usr/share/shorewall/functions" >> $f
|
echo ". ${SHAREDIR}/functions" >> $f
|
||||||
echo >> $f
|
echo >> $f
|
||||||
grep '^MODULE' /var/lib/shorewall/restore-base >> $f
|
grep '^MODULE' ${VARDIR}/restore-base >> $f
|
||||||
echo "reload_kernel_modules << __EOF__" >> $f
|
echo "reload_kernel_modules << __EOF__" >> $f
|
||||||
grep 'loadmodule ip_set' /var/lib/shorewall/restore-base >> $f
|
grep 'loadmodule ip_set' ${VARDIR}/restore-base >> $f
|
||||||
echo "__EOF__" >> $f
|
echo "__EOF__" >> $f
|
||||||
echo >> $f
|
echo >> $f
|
||||||
echo "ipset -U :all: :all:" >> $f
|
echo "ipset -U :all: :all:" >> $f
|
||||||
@ -438,11 +442,11 @@ save_config() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
rm -f /var/lib/shorewall/restore-$$
|
rm -f ${VARDIR}/restore-$$
|
||||||
echo " ERROR: Currently-running Configuration Not Saved"
|
echo " ERROR: Currently-running Configuration Not Saved"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo " ERROR: /var/lib/shorewall/.restored oes not exist"
|
echo " ERROR: ${VARDIR}/.restored oes not exist"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Error Saving the Dynamic Rules"
|
echo "Error Saving the Dynamic Rules"
|
||||||
@ -465,10 +469,10 @@ start_command() {
|
|||||||
do_it() {
|
do_it() {
|
||||||
[ -n "$nolock" ] || mutex_on
|
[ -n "$nolock" ] || mutex_on
|
||||||
|
|
||||||
if [ -x /usr/share/shorewall/firewall ]; then
|
if [ -x ${SHAREDIR}/firewall ]; then
|
||||||
/usr/share/shorewall/firewall $debugging start
|
${SHAREDIR}/firewall $debugging start
|
||||||
else
|
else
|
||||||
error_message "/etc/shorewall/firewall is missing or is not executable"
|
error_message "${CONFDIR}/firewall is missing or is not executable"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "$nolock" ] || mutex_off
|
[ -n "$nolock" ] || mutex_off
|
||||||
@ -537,12 +541,12 @@ start_command() {
|
|||||||
#
|
#
|
||||||
# RESTOREFILE is exported by get_config()
|
# RESTOREFILE is exported by get_config()
|
||||||
#
|
#
|
||||||
make -qf /etc/shorewall/Makefile || FAST=
|
make -qf ${CONFDIR}/Makefile || FAST=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$FAST" ]; then
|
if [ -n "$FAST" ]; then
|
||||||
|
|
||||||
RESTOREPATH=/var/lib/shorewall/$RESTOREFILE
|
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||||
|
|
||||||
if [ -x $RESTOREPATH ]; then
|
if [ -x $RESTOREPATH ]; then
|
||||||
if [ -x ${RESTOREPATH}-ipsets ]; then
|
if [ -x ${RESTOREPATH}-ipsets ]; then
|
||||||
@ -558,7 +562,7 @@ start_command() {
|
|||||||
|
|
||||||
echo Restoring Shorewall...
|
echo Restoring Shorewall...
|
||||||
$SHOREWALL_SHELL $RESTOREPATH restore
|
$SHOREWALL_SHELL $RESTOREPATH restore
|
||||||
date > /var/lib/shorewall/restarted
|
date > ${VARDIR}/restarted
|
||||||
progress_message3 Shorewall restored from $RESTOREPATH
|
progress_message3 Shorewall restored from $RESTOREPATH
|
||||||
else
|
else
|
||||||
do_it
|
do_it
|
||||||
@ -632,10 +636,10 @@ restart_command() {
|
|||||||
|
|
||||||
[ -n "$nolock" ] || mutex_on
|
[ -n "$nolock" ] || mutex_on
|
||||||
|
|
||||||
if [ -x /usr/share/shorewall/firewall ]; then
|
if [ -x ${SHAREDIR}/firewall ]; then
|
||||||
$SHOREWALL_SHELL /usr/share/shorewall/firewall $debugging restart
|
$SHOREWALL_SHELL ${SHAREDIR}/firewall $debugging restart
|
||||||
else
|
else
|
||||||
error_message "/etc/shorewall/firewall is missing or is not executable"
|
error_message "${SHAREDIR}/firewall is missing or is not executable"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "$nolock" ] || mutex_off
|
[ -n "$nolock" ] || mutex_off
|
||||||
@ -728,7 +732,7 @@ show_command() {
|
|||||||
;;
|
;;
|
||||||
zones)
|
zones)
|
||||||
[ $# -gt 1 ] && usage 1
|
[ $# -gt 1 ] && usage 1
|
||||||
if [ -f /var/lib/shorewall/zones ]; then
|
if [ -f ${VARDIR}/zones ]; then
|
||||||
echo "Shorewall-$version Zones at $HOSTNAME - $(date)"
|
echo "Shorewall-$version Zones at $HOSTNAME - $(date)"
|
||||||
echo
|
echo
|
||||||
while read zone type hosts; do
|
while read zone type hosts; do
|
||||||
@ -736,10 +740,10 @@ show_command() {
|
|||||||
for host in $hosts; do
|
for host in $hosts; do
|
||||||
echo " $host"
|
echo " $host"
|
||||||
done
|
done
|
||||||
done < /var/lib/shorewall/zones
|
done < ${VARDIR}/zones
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
echo " ERROR: /var/lib/shorewall/zones does not exist" >&2
|
echo " ERROR: ${VARDIR}/zones does not exist" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -922,7 +926,7 @@ restore_command() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
RESTOREPATH=/var/lib/shorewall/$RESTOREFILE
|
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||||
|
|
||||||
export NOROUTES
|
export NOROUTES
|
||||||
|
|
||||||
@ -937,10 +941,10 @@ restore_command() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
progress_message3 "Restoring Shorewall..."
|
progress_message3 "Restoring Shorewall..."
|
||||||
$SHOREWALL_SHELL $RESTOREPATH restore && echo "Shorewall restored from /var/lib/shorewall/$RESTOREFILE"
|
$SHOREWALL_SHELL $RESTOREPATH restore && echo "Shorewall restored from ${VARDIR}/$RESTOREFILE"
|
||||||
[ -n "$nolock" ] || mutex_off
|
[ -n "$nolock" ] || mutex_off
|
||||||
else
|
else
|
||||||
echo "File /var/lib/shorewall/$RESTOREFILE: file not found"
|
echo "File ${VARDIR}/$RESTOREFILE: file not found"
|
||||||
[ -n "$nolock" ] || mutex_off
|
[ -n "$nolock" ] || mutex_off
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
@ -994,8 +998,8 @@ usage() # $1 = exit status
|
|||||||
# Display the time that the counters were last reset
|
# Display the time that the counters were last reset
|
||||||
#
|
#
|
||||||
show_reset() {
|
show_reset() {
|
||||||
[ -f /var/lib/shorewall/restarted ] && \
|
[ -f ${VARDIR}/restarted ] && \
|
||||||
echo "Counters reset $(cat /var/lib/shorewall/restarted)" && \
|
echo "Counters reset $(cat ${VARDIR}/restarted)" && \
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1170,7 +1174,7 @@ fi
|
|||||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
||||||
MUTEX_TIMEOUT=
|
MUTEX_TIMEOUT=
|
||||||
|
|
||||||
SHARED_DIR=/usr/share/shorewall
|
SHARED_DIR=${SHAREDIR}
|
||||||
FIREWALL=$SHARED_DIR/firewall
|
FIREWALL=$SHARED_DIR/firewall
|
||||||
FUNCTIONS=$SHARED_DIR/functions
|
FUNCTIONS=$SHARED_DIR/functions
|
||||||
VERSION_FILE=$SHARED_DIR/version
|
VERSION_FILE=$SHARED_DIR/version
|
||||||
@ -1280,8 +1284,8 @@ case "$COMMAND" in
|
|||||||
status=4
|
status=4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /var/lib/shorewall/state ]; then
|
if [ -f ${VARDIR}/state ]; then
|
||||||
state="$(cat /var/lib/shorewall/state)"
|
state="$(cat ${VARDIR}/state)"
|
||||||
case $state in
|
case $state in
|
||||||
Stopped*|Clear*)
|
Stopped*|Clear*)
|
||||||
status=3
|
status=3
|
||||||
@ -1496,7 +1500,7 @@ case "$COMMAND" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
RESTOREPATH=/var/lib/shorewall/$RESTOREFILE
|
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||||
|
|
||||||
[ "$nolock" ] || mutex_on
|
[ "$nolock" ] || mutex_on
|
||||||
|
|
||||||
@ -1518,7 +1522,7 @@ case "$COMMAND" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
RESTOREPATH=/var/lib/shorewall/$RESTOREFILE
|
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||||
|
|
||||||
if [ -x $RESTOREPATH ]; then
|
if [ -x $RESTOREPATH ]; then
|
||||||
|
|
||||||
@ -1533,7 +1537,7 @@ case "$COMMAND" in
|
|||||||
elif [ -f $RESTOREPATH ]; then
|
elif [ -f $RESTOREPATH ]; then
|
||||||
echo " $RESTOREPATH exists and is not a saved Shorewall configuration"
|
echo " $RESTOREPATH exists and is not a saved Shorewall configuration"
|
||||||
fi
|
fi
|
||||||
rm -f /var/lib/shorewall/save
|
rm -f ${VARDIR}/save
|
||||||
;;
|
;;
|
||||||
ipcalc)
|
ipcalc)
|
||||||
[ -n "$debugging" ] && set -x
|
[ -n "$debugging" ] && set -x
|
||||||
@ -1588,7 +1592,7 @@ case "$COMMAND" in
|
|||||||
call)
|
call)
|
||||||
[ -n "$debugging" ] && set -x
|
[ -n "$debugging" ] && set -x
|
||||||
#
|
#
|
||||||
# Undocumented way to call functions in /usr/share/shorewall/functions directly
|
# Undocumented way to call functions in ${SHAREDIR}/functions directly
|
||||||
#
|
#
|
||||||
shift
|
shift
|
||||||
$@
|
$@
|
||||||
|
Loading…
Reference in New Issue
Block a user