Create the 'show saves' command.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2018-02-14 10:37:05 -08:00
parent db4a26cfa9
commit 8056b6fd85
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10
2 changed files with 46 additions and 5 deletions

View File

@ -87,6 +87,8 @@ showchain() # $1 = name of chain
#
validate_restorefile() # $* = label
{
[ -n "$RESTOREFILE" ] || RESTOREFILE=restore
case $RESTOREFILE in
*/*)
error_message "ERROR: $@ must specify a simple file name: $RESTOREFILE"
@ -1189,6 +1191,26 @@ show_ipsec_command() {
show_ipsec
}
show_saves_command() {
local f
local fn
local mtime
echo "$g_product $SHOREWALL_VERSION Saves at $g_hostname - $(date)"
echo "Saved snapshots are:"
echo
for f in ${VARDIR}/*-iptables; do
fn=$(basename $f)
fn=${fn%-iptables}
mtime=$(ls -lt $f | tail -n 1 | cut -d ' ' -f '6 7 8' )
[ $fn = "$RESTOREFILE" ] && fn="$fn (default)"
echo " $mtime ${fn%-iptables}"
done
echo
}
#
# Show Command Executor
#
@ -1478,6 +1500,10 @@ show_command() {
only_root
eval show_ipsec_command $g_pager
;;
saves)
[ $# -gt 1 ] && too_many_arguments $2
show_saves_command
;;
*)
case "$PRODUCT" in
*-lite)
@ -4348,6 +4374,7 @@ usage() # $1 = exit status
echo " [ show | list | ls ] opens"
echo " [ show | list | ls ] policies"
echo " [ show | list | ls ] routing"
echo " [ show | list | ls ] saves"
echo " [ show | list | ls ] tc [ device ]"
echo " [ show | list | ls ] vardir"
echo " [ show | list | ls ] zones"

View File

@ -799,7 +799,7 @@
<arg choice="req"><option>show | list | ls </option></arg>
<arg choice="plain"><option>tc</option></arg>
<arg choice="plain"><option>saves</option></arg>
</cmdsynopsis>
<cmdsynopsis>
@ -2359,11 +2359,11 @@
<replaceable>filename</replaceable> ]</term>
<listitem>
<para>The dynamic blacklist is stored in /var/lib/shorewall/save.
The state of the firewall is stored in
<para>Creates a snapshot of the currently running firewall. The
dynamic blacklist is stored in /var/lib/shorewall/save. The state of
the firewall is stored in
/var/lib/shorewall/<emphasis>filename</emphasis> for use by the
<emphasis role="bold">shorewall restore</emphasis> and <emphasis
role="bold">shorewall -f start</emphasis> commands. If
<emphasis role="bold">shorewall restore</emphasis> command. If
<emphasis>filename</emphasis> is not given then the state is saved
in the file specified by the RESTOREFILE option in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5)
@ -2691,6 +2691,20 @@
</listitem>
</varlistentry>
<varlistentry>
<term>saves</term>
<listitem>
<para>Added in Shorewall 5.2.0. Lists snapshots created by the
<command>save</command> command. Each snapshot is listed with
the date and time when it was taken. If there is a snapshot
with the name specified in the RESTOREFILE option in <ulink
url="shorewall.conf.html">shorewall.conf(5</ulink>), that
snapshot is listed as the <emphasis>default</emphasis>
snapshot for the <command>restore</command> command.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">tc</emphasis></term>