mirror of
https://gitlab.com/shorewall/code.git
synced 2024-11-21 23:23:13 +01:00
Make 'show actions' more robust
- Show all lines, including continuation and compiler directives - Show both actions and actions.std entries - The actions file need not reside in /etc/shorewall[6] but may be in any directory on the CONFIG_PATH Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
5cc626fa1d
commit
c9512dfaf8
@ -937,11 +937,28 @@ show_events() {
|
||||
fi
|
||||
}
|
||||
|
||||
sort_actions() {
|
||||
local sep #separates sort keys from the action[.std] record
|
||||
sep="##"
|
||||
|
||||
awk -v sep="$sep" \
|
||||
'BEGIN { action = ""; ifrec = ""; nr = 0; };\
|
||||
/^#/ { next; };\
|
||||
/^\?(if|IF|If)/ { ifrec = $0; nr = NR; next; };\
|
||||
/^( |\t|\?)/ { if ( action != "" ) print action, NR, sep $0; next; };\
|
||||
{ action = $1; };\
|
||||
nr != 0 { print action , nr, sep ifrec; nr = 0; };\
|
||||
{ print action , NR, sep $0; }' | sort -k 1,2 | sed "s/^.*${sep}//"
|
||||
}
|
||||
|
||||
show_actions() {
|
||||
if [ -f ${g_confdir}/actions ]; then
|
||||
cat ${g_sharedir}/actions.std ${g_confdir}/actions | grep -Ev '^[#?[:space:]]|^$'
|
||||
local actions
|
||||
actions=$(find_file actions)
|
||||
|
||||
if [ -f ${actions} ]; then
|
||||
cat ${actions} ${g_sharedir}/actions.std | sort_actions
|
||||
else
|
||||
grep -Ev '^[#?[:space:]]|^$' ${g_sharedir}/actions.std
|
||||
sort_actions < ${g_sharedir}/actions.std
|
||||
fi
|
||||
}
|
||||
|
||||
@ -1108,10 +1125,6 @@ show_blacklists() {
|
||||
show_bl;
|
||||
}
|
||||
|
||||
show_actions_sorted() {
|
||||
show_actions | sort -u -k 1,1
|
||||
}
|
||||
|
||||
show_macros() {
|
||||
for directory in $(split $CONFIG_PATH); do
|
||||
temp=
|
||||
@ -1543,7 +1556,7 @@ show_command() {
|
||||
;;
|
||||
actions)
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
eval show_actions_sorted $g_pager
|
||||
eval show_actions $g_pager
|
||||
return
|
||||
;;
|
||||
macro)
|
||||
|
Loading…
Reference in New Issue
Block a user