Added FIREHOL_AUTOSAVE variable that controls the file that is saved with

the 'save' argument of FireHOL. By default this variable is empty in which
case FireHOL detects RedHat and Debian systems and saves it to the right
place.
This commit is contained in:
ktsaou 2003-03-14 20:36:52 +00:00
parent 65dbe74904
commit e0b1570dd2
2 changed files with 44 additions and 11 deletions

@ -1045,6 +1045,19 @@ about optional rule parameters that should not be used in certain commands.
Example: <b>FIREHOL_NAT="1"</b>
<p>
<hr noshade size=1 width="100%">
<a name="FIREHOL_AUTOSAVE"><h3><b>FIREHOL_AUTOSAVE</b></h3></a>
<H4>Description</H4>
FIREHOL_AUTOSAVE controls the file that will be created when FireHOL is called with the <b>save</b> command line argument.
If this variable is empty (the default), FireHOL will try to detect where to save the file. Currently, the RedHat way
(/etc/sysconfig/iptables) and the Debian way (/var/lib/iptables/autosave) are automatically detected (in the order given here)
based on the existance of the directory this file should be created in.
<p>
Default: <b>FIREHOL_AUTOSAVE=""</b>
<br>
Example: <b>FIREHOL_AUTOSAVE="/tmp/firehol-saved.txt"</b>
<p>
<table border=0 cellpadding=10 cellspacing=0 width="100%"><tr bgcolor="#777777"><td align=center><font color="white"><b><big><a name="use_variables">Variables that FireHOL offers</a></td</tr></table>
<p>
@ -1082,7 +1095,7 @@ about optional rule parameters that should not be used in certain commands.
<tr><td align=center valign=middle>
<A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=58425&amp;type=5" width="210" height="62" border="0" alt="SourceForge Logo"></A>
</td><td align=center valign=middle>
<small>$Id: commands.html,v 1.21 2003/02/26 22:26:19 ktsaou Exp $</small>
<small>$Id: commands.html,v 1.22 2003/03/14 20:36:55 ktsaou Exp $</small>
<p>
<b>FireHOL</b>, a firewall for humans...<br>
&copy; Copyright 2002

@ -10,7 +10,7 @@
#
# config: /etc/firehol.conf
#
# $Id: firehol.sh,v 1.109 2003/03/07 23:34:29 ktsaou Exp $
# $Id: firehol.sh,v 1.110 2003/03/14 20:36:52 ktsaou Exp $
#
FIREHOL_FILE="${0}"
@ -95,6 +95,10 @@ FIREHOL_OUTPUT="${FIREHOL_DIR}/firehol-out.sh"
FIREHOL_SAVED="${FIREHOL_DIR}/firehol-save.sh"
FIREHOL_TMP="${FIREHOL_DIR}/firehol-tmp.sh"
# Where /etc/init.d/iptables expects its configuration?
# Leave it empty for automatic detection
FIREHOL_AUTOSAVE=
# ----------------------------------------------------------------------
# This is our version number. It is increased when the configuration
@ -3189,7 +3193,7 @@ case "${arg}" in
else
cat <<"EOF"
$Id: firehol.sh,v 1.109 2003/03/07 23:34:29 ktsaou Exp $
$Id: firehol.sh,v 1.110 2003/03/14 20:36:52 ktsaou Exp $
(C) Copyright 2002, Costa Tsaousis <costa@tsaousis.gr>
FireHOL is distributed under GPL.
@ -3372,7 +3376,7 @@ then
cat <<"EOF"
$Id: firehol.sh,v 1.109 2003/03/07 23:34:29 ktsaou Exp $
$Id: firehol.sh,v 1.110 2003/03/14 20:36:52 ktsaou Exp $
(C) Copyright 2002, Costa Tsaousis <costa@tsaousis.gr>
FireHOL is distributed under GPL.
Home Page: http://firehol.sourceforge.net
@ -3580,7 +3584,7 @@ then
cat >&2 <<"EOF"
$Id: firehol.sh,v 1.109 2003/03/07 23:34:29 ktsaou Exp $
$Id: firehol.sh,v 1.110 2003/03/14 20:36:52 ktsaou Exp $
(C) Copyright 2002, Costa Tsaousis <costa@tsaousis.gr>
FireHOL is distributed under GPL.
Home Page: http://firehol.sourceforge.net
@ -3673,7 +3677,7 @@ EOF
echo "# "
cat <<"EOF"
# $Id: firehol.sh,v 1.109 2003/03/07 23:34:29 ktsaou Exp $
# $Id: firehol.sh,v 1.110 2003/03/14 20:36:52 ktsaou Exp $
# (C) Copyright 2002, Costa Tsaousis <costa@tsaousis.gr>
# FireHOL is distributed under GPL.
# Home Page: http://firehol.sourceforge.net
@ -4234,18 +4238,34 @@ touch /var/lock/subsys/firehol
if [ ${FIREHOL_SAVE} -eq 1 ]
then
# /etc/init.d/iptables save
echo -n $"FireHOL: Saving firewall to /etc/sysconfig/iptables:"
fixed_iptables_save >/etc/sysconfig/iptables
if [ -z "${FIREHOL_AUTOSAVE}" ]
then
if [ -d "/etc/sysconfig" ]
then
#
FIREHOL_AUTOSAVE="/etc/sysconfig/iptables"
elif [ -d "/var/lib/iptables" ]
then
FIREHOL_AUTOSAVE="/var/lib/iptables/autosave"
else
error "Cannot find where to save iptables file. Please set FIREHOL_AUTOSAVE."
echo
exit 1
fi
fi
echo -n $"FireHOL: Saving firewall to ${FIREHOL_AUTOSAVE}:"
fixed_iptables_save >"${FIREHOL_AUTOSAVE}"
if [ ! $? -eq 0 ]
then
failure $"FireHOL: Saving firewall to /etc/sysconfig/iptables:"
failure $"FireHOL: Saving firewall to ${FIREHOL_AUTOSAVE}:"
echo
exit 1
fi
success $"FireHOL: Saving firewall to /etc/sysconfig/iptables:"
success $"FireHOL: Saving firewall to ${FIREHOL_AUTOSAVE}:"
echo
exit 0
fi