Implement 'run' command

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2014-07-28 07:04:56 -07:00
parent ad6c91bcbd
commit a7b18ca875
7 changed files with 127 additions and 0 deletions

View File

@ -3574,6 +3574,7 @@ usage() # $1 = exit status
echo " start [ -f ] [ -p ] [ <directory> ]" echo " start [ -f ] [ -p ] [ <directory> ]"
echo " stop" echo " stop"
echo " status [ -i ]" echo " status [ -i ]"
echo " run <function> [ function ... ]"
echo " version [ -a ]" echo " version [ -a ]"
echo echo
exit $1 exit $1
@ -3818,6 +3819,14 @@ shorewall_cli() {
fatal_error "$g_product is not running" fatal_error "$g_product is not running"
fi fi
;; ;;
run)
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
;;
show|list|ls) show|list|ls)
get_config Yes No Yes get_config Yes No Yes
shift shift

View File

@ -317,6 +317,21 @@
<arg><replaceable>filename</replaceable></arg> <arg><replaceable>filename</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>shorewall-lite</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>run</option></arg>
<arg choice="plain">function</arg>
<arg><replaceable>parameter ...</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>shorewall-lite</command> <command>shorewall-lite</command>
@ -807,6 +822,19 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<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>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">save</emphasis></term> <term><emphasis role="bold">save</emphasis></term>

View File

@ -17,6 +17,7 @@ usage() {
echo " reset" echo " reset"
echo " refresh" echo " refresh"
echo " restart" echo " restart"
echo " run <function> [ <argument> ... ]"
echo " status" echo " status"
echo " up <interface>" echo " up <interface>"
echo " version" echo " version"
@ -371,6 +372,10 @@ case "$COMMAND" in
fi fi
status=0 status=0
;; ;;
run)
shift
eval $@
;;
version) version)
[ $# -ne 1 ] && usage 2 [ $# -ne 1 ] && usage 2
echo $SHOREWALL_VERSION echo $SHOREWALL_VERSION

View File

@ -1666,6 +1666,7 @@ usage() # $1 = exit status
echo " reset [ <chain> ... ]" echo " reset [ <chain> ... ]"
echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ <directory> ]" echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ <directory> ]"
echo " restore [ -n ] [ <file name> ]" echo " restore [ -n ] [ <file name> ]"
echo " run <function> [ <argument> ... ]"
echo " safe-restart [ -t <timeout> ] [ <directory> ]" echo " safe-restart [ -t <timeout> ] [ <directory> ]"
echo " safe-start [ -t <timeout> ] [ <directory> ]" echo " safe-start [ -t <timeout> ] [ <directory> ]"
echo " save [ <file name> ]" echo " save [ <file name> ]"

View File

@ -457,6 +457,21 @@
<arg><replaceable>filename</replaceable></arg> <arg><replaceable>filename</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>shorewall</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>run</option></arg>
<arg choice="plain">function</arg>
<arg><replaceable>parameter ...</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>shorewall</command> <command>shorewall</command>
@ -1409,6 +1424,19 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<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>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">safe-restart</emphasis></term> <term><emphasis role="bold">safe-restart</emphasis></term>

View File

@ -317,6 +317,21 @@
<arg><replaceable>filename</replaceable></arg> <arg><replaceable>filename</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>shorewall6-lite</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>run</option></arg>
<arg choice="plain">function</arg>
<arg><replaceable>parameter ...</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>shorewall6-lite</command> <command>shorewall6-lite</command>
@ -805,6 +820,19 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<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>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">save</emphasis></term> <term><emphasis role="bold">save</emphasis></term>

View File

@ -406,6 +406,21 @@
<arg><replaceable>filename</replaceable></arg> <arg><replaceable>filename</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>shorewall6</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>run</option></arg>
<arg choice="plain">function</arg>
<arg><replaceable>parameter ...</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>shorewall6</command> <command>shorewall6</command>
@ -1290,6 +1305,19 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<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>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">safe-restart</emphasis></term> <term><emphasis role="bold">safe-restart</emphasis></term>