mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-21 22:01:57 +01:00
Make 'call' a supported command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
e3805b0ada
commit
ba7afcaeae
@ -42,16 +42,6 @@ fi
|
||||
|
||||
. ${SHAREDIR}/shorewall/lib.base
|
||||
|
||||
|
||||
#
|
||||
# Fatal Error
|
||||
#
|
||||
fatal_error() # $@ = Message
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Issue an error message and die
|
||||
#
|
||||
@ -4239,10 +4229,29 @@ shorewall_cli() {
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
#
|
||||
# Undocumented way to call functions in the libraries directly
|
||||
# Way to call functions in the libraries directly
|
||||
#
|
||||
shift
|
||||
$@
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
#
|
||||
# First look for it here
|
||||
#
|
||||
if type $1 2> /dev/null | fgrep -q 'is a function'; then
|
||||
#
|
||||
# It's a shell function -- call it
|
||||
#
|
||||
$@
|
||||
else
|
||||
#
|
||||
# It isn't a function visible to this script -- try
|
||||
# the compiled firewall
|
||||
#
|
||||
run_it $g_firewall $g_debugging call $@
|
||||
fi
|
||||
else
|
||||
usage 1
|
||||
fi
|
||||
;;
|
||||
help)
|
||||
shift
|
||||
|
@ -70,6 +70,15 @@ startup_error() # $* = Error Message
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Fatal Error
|
||||
#
|
||||
fatal_error() # $@ = Message
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Get the Shorewall version of the passed script
|
||||
#
|
||||
|
@ -47,6 +47,19 @@
|
||||
<arg choice="plain"><replaceable>address</replaceable></arg>
|
||||
</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>allow</option></arg>
|
||||
|
||||
<arg choice="plain"><replaceable>address</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
@ -665,6 +678,24 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">call <replaceable>function</replaceable> [
|
||||
<replaceable>parameter</replaceable> ... ]</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.10. Allows you to call a function in
|
||||
one of the Shorewall libraries or in your compiled script. function
|
||||
must name the shell function to be called. The listed parameters are
|
||||
passed to the function.</para>
|
||||
|
||||
<para>The function is first searched for in
|
||||
<filename>lib.base</filename>, <filename>lib.common</filename>,
|
||||
<filename>lib.cli</filename> and <filename>lib.cli-std</filename>
|
||||
(Shorewall and Shorewall6 only). If it is not found, the call
|
||||
command is passed to the generated script to be executed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">clear
|
||||
</emphasis>[-<option>f</option>]</term>
|
||||
|
@ -429,11 +429,27 @@ case "$COMMAND" in
|
||||
;;
|
||||
call)
|
||||
#
|
||||
# Undocumented way to call functions in the libraries directly
|
||||
# Way to call functions in the generated script directly
|
||||
#
|
||||
detect_configuration
|
||||
|
||||
shift
|
||||
$@
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
#
|
||||
# See what it is
|
||||
#
|
||||
if type $1 2> /dev/null | fgrep -q 'is a function'; then
|
||||
#
|
||||
# It's a shell function -- call it
|
||||
#
|
||||
$@
|
||||
else
|
||||
fatal_error "$1 is not a known shell function"
|
||||
fi
|
||||
else
|
||||
usage 1
|
||||
fi
|
||||
;;
|
||||
version)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
|
@ -49,6 +49,21 @@
|
||||
<arg choice="plain"><replaceable>address</replaceable></arg>
|
||||
</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>call</option></arg>
|
||||
|
||||
<arg
|
||||
choice="plain"><replaceable>function</replaceable><arg><replaceable>parameter</replaceable>
|
||||
...</arg></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall</command>
|
||||
|
||||
@ -918,6 +933,24 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">call <replaceable>function</replaceable> [
|
||||
<replaceable>parameter</replaceable> ... ]</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.10. Allows you to call a function in
|
||||
one of the Shorewall libraries or in your compiled script. function
|
||||
must name the shell function to be called. The listed parameters are
|
||||
passed to the function.</para>
|
||||
|
||||
<para>The function is first searched for in
|
||||
<filename>lib.base</filename>, <filename>lib.common</filename>,
|
||||
<filename>lib.cli</filename> and <filename>lib.cli-std</filename>
|
||||
(Shorewall and Shorewall6 only). If it is not found, the call
|
||||
command is passed to the generated script to be executed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">check</emphasis> [-<option>e</option>]
|
||||
[-<option>d</option>] [-<option>p</option>] [-<option>r</option>]
|
||||
|
@ -47,6 +47,21 @@
|
||||
<arg choice="plain"><replaceable>address</replaceable></arg>
|
||||
</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>call</option></arg>
|
||||
|
||||
<arg
|
||||
choice="plain"><replaceable>function</replaceable><arg><replaceable>parameter</replaceable>
|
||||
...</arg></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall6-lite</command>
|
||||
|
||||
@ -655,6 +670,24 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">call <replaceable>function</replaceable> [
|
||||
<replaceable>parameter</replaceable> ... ]</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.10. Allows you to call a function in
|
||||
one of the Shorewall libraries or in your compiled script. function
|
||||
must name the shell function to be called. The listed parameters are
|
||||
passed to the function.</para>
|
||||
|
||||
<para>The function is first searched for in
|
||||
<filename>lib.base</filename>, <filename>lib.common</filename>,
|
||||
<filename>lib.cli</filename> and <filename>lib.cli-std</filename>
|
||||
(Shorewall and Shorewall6 only). If it is not found, the call
|
||||
command is passed to the generated script to be executed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">clear </emphasis><emphasis role="bold">
|
||||
</emphasis>[-<option>f</option>]</term>
|
||||
|
@ -48,6 +48,21 @@
|
||||
<arg choice="plain"><replaceable>address</replaceable></arg>
|
||||
</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>call</option></arg>
|
||||
|
||||
<arg
|
||||
choice="plain"><replaceable>function</replaceable><arg><replaceable>parameter</replaceable>
|
||||
...</arg></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall6</command>
|
||||
|
||||
@ -848,6 +863,24 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">call <replaceable>function</replaceable> [
|
||||
<replaceable>parameter</replaceable> ... ]</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.10. Allows you to call a function in
|
||||
one of the Shorewall libraries or in your compiled script. function
|
||||
must name the shell function to be called. The listed parameters are
|
||||
passed to the function.</para>
|
||||
|
||||
<para>The function is first searched for in
|
||||
<filename>lib.base</filename>, <filename>lib.common</filename>,
|
||||
<filename>lib.cli</filename> and <filename>lib.cli-std</filename>
|
||||
(Shorewall and Shorewall6 only). If it is not found, the call
|
||||
command is passed to the generated script to be executed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">check </emphasis>[-<option>e</option>]
|
||||
[-<option>d</option>] [-<option>p</option>] [-<option>r</option>]
|
||||
|
Loading…
Reference in New Issue
Block a user