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

View File

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

View File

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

View File

@ -1615,6 +1615,15 @@ export_command() # $* = original arguments less the command.
fi 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 # Give Usage Information
# #

View File

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

View File

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

View File

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