Refine the 'run' command

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2014-07-29 10:30:07 -07:00
parent eb5026d3b7
commit 31e5aeeaea
7 changed files with 61 additions and 30 deletions

View File

@ -3515,6 +3515,14 @@ restart_command() {
return $rc
}
run_command() {
if [ -x ${VARDIR}/firewall ] ; then
run_it ${VARDIR}/firewall $g_debugging $@
else
fatal_error "${VARDIR}/firewall does not exist or is not executable"
fi
}
#
# Give Usage Information
#
@ -3820,12 +3828,9 @@ shorewall_cli() {
fi
;;
run)
[ $# -gt 1 ] || fatal_error "Missing function name"
get_config Yes
if [ -x ${VARDIR}/firewall ] ; then
run_it ${VARDIR}/firewall $g_debugging $@
else
fatal_error "${VARDIR}/firewall does not exist or is not executable"
fi
run_command $@
;;
show|list|ls)
get_config Yes No Yes

View File

@ -841,12 +841,11 @@
<term><emphasis role="bold">run</emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.3. Calls the named
<replaceable>function</replaceable> passing the supplied
<replaceable>parameter</replaceable>s. The
<replaceable>function</replaceable> will normally be declared in
<filename>lib.private</filename> and is executed in the context of
the generated firewall script.</para>
<para>Added in Shorewall 4.6.3. Executes
<replaceable>command</replaceable> in the context of the generated
script passing the supplied <replaceable>parameter</replaceable>s.
Normally, the <replaceable>command</replaceable> will be a function
declared in <filename>lib.private</filename>.</para>
</listitem>
</varlistentry>

View File

@ -374,7 +374,9 @@ case "$COMMAND" in
;;
run)
shift
detect_configuration
eval $@
status=$?
;;
version)
[ $# -ne 1 ] && usage 2

View File

@ -1615,6 +1615,15 @@ export_command() # $* = original arguments less the command.
fi
}
run_command() {
if [ -x ${VARDIR}/firewall ] ; then
uptodate ${VARDIR}/firewall || echo " WARNING: ${VARDIR}/firewall is not up to date" >&2
run_it ${VARDIR}/firewall $g_debugging $@
else
fatal_error "${VARDIR}/firewall does not exist or is not executable"
fi
}
#
# Give Usage Information
#

View File

@ -1428,12 +1428,20 @@
<term><emphasis role="bold">run</emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.3. Calls the named
<replaceable>function</replaceable> passing the supplied
<replaceable>parameter</replaceable>s. The
<replaceable>function</replaceable> will normally be declared in
<filename>lib.private</filename> and is executed in the context of
the generated firewall script.</para>
<para>Added in Shorewall 4.6.3. Executes
<replaceable>command</replaceable> in the context of the generated
script passing the supplied <replaceable>parameter</replaceable>s.
Normally, the <replaceable>command</replaceable> will be a function
declared in <filename>lib.private</filename>.</para>
<para>If there are files in the CONFIG_PATH that were modified after
the current firewall script was generated, the following warning
message is issued:</para>
<simplelist>
<member>WARNING: /var/lib/shorewall/firewall is not up to
date</member>
</simplelist>
</listitem>
</varlistentry>

View File

@ -327,7 +327,7 @@
<arg choice="plain"><option>run</option></arg>
<arg choice="plain">function</arg>
<arg choice="plain">command</arg>
<arg><replaceable>parameter ...</replaceable></arg>
</cmdsynopsis>
@ -839,12 +839,11 @@
<term><emphasis role="bold">run</emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.3. Calls the named
<replaceable>function</replaceable> passing the supplied
<replaceable>parameter</replaceable>s. The
<replaceable>function</replaceable> will normally be declared in
<filename>lib.private</filename> and is executed in the context of
the generated firewall script.</para>
<para>Added in Shorewall 4.6.3. Executes
<replaceable>command</replaceable> in the context of the generated
script passing the supplied <replaceable>parameter</replaceable>s.
Normally, the <replaceable>command</replaceable> will be a function
declared in <filename>lib.private</filename>.</para>
</listitem>
</varlistentry>

View File

@ -1309,12 +1309,21 @@
<term><emphasis role="bold">run</emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.3. Calls the named
<replaceable>function</replaceable> passing the supplied
<replaceable>parameter</replaceable>s. The
<replaceable>function</replaceable> will normally be declared in
<filename>lib.private</filename> and is executed in the context of
the generated firewall script.</para>
<para>Added in Shorewall 4.6.3. Executes
<replaceable>command</replaceable> in the context of the generated
script passing the supplied <replaceable>parameter</replaceable>s.
Normally, the <replaceable>command</replaceable> will be a function
declared in <filename>lib.private</filename>.</para>
<para>If there are files in the CONFIG_PATH that were modified after
the current firewall script was generated, the following warning
message is issued before the script's run command is
executed:</para>
<simplelist>
<member>WARNING: /var/lib/shorewall6/firewall is not up to
date</member>
</simplelist>
</listitem>
</varlistentry>