mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 00:07:26 +00:00
interfaces: teach ifctl to dump all files and its data for an interface
This commit is contained in:
parent
15c0788e50
commit
e2ada5baaf
@ -1,5 +1,5 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2022 Franco Fichtner <franco@opnsense.org>
|
||||
.\" Copyright (c) 2022-2023 Franco Fichtner <franco@opnsense.org>
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
@ -24,7 +24,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd July 25, 2022
|
||||
.Dd August 29, 2023
|
||||
.Dt IFCTL 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -35,7 +35,7 @@
|
||||
.Op Fl i Ar device
|
||||
.Op Fl 46
|
||||
.Op Fl nprs
|
||||
.Op Fl a Ar data | Fl c | Fl d | Fl l
|
||||
.Op Fl a Ar data | Fl c | Fl d | Fl l | Fl O
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
@ -95,6 +95,11 @@ not using the interface option
|
||||
.It Fl n
|
||||
Use name server mode.
|
||||
This is the default.
|
||||
.It Fl O
|
||||
Dump mode is similar to
|
||||
.Sq Fl l ,
|
||||
but prints all the available file names and their data for the
|
||||
specified interface.
|
||||
.It Fl p
|
||||
Use prefix delegation mode.
|
||||
.It Fl r
|
||||
|
||||
@ -27,6 +27,8 @@ DO_COMMAND=
|
||||
DO_CONTENTS=
|
||||
DO_VERBOSE=
|
||||
|
||||
FILES="nameserver prefix router searchdomain"
|
||||
|
||||
AF=
|
||||
MD=
|
||||
EX=
|
||||
@ -55,7 +57,7 @@ flush_routes()
|
||||
# default to IPv4 with nameserver mode
|
||||
set -- -4 -n ${@}
|
||||
|
||||
while getopts 46a:cdi:lnprsV OPT; do
|
||||
while getopts 46a:cdi:lnOprsV OPT; do
|
||||
case ${OPT} in
|
||||
4)
|
||||
AF=inet
|
||||
@ -70,7 +72,7 @@ while getopts 46a:cdi:lnprsV OPT; do
|
||||
;;
|
||||
c)
|
||||
DO_COMMAND="-c"
|
||||
MD="nameserver prefix router searchdomain"
|
||||
MD="${FILES}"
|
||||
;;
|
||||
d)
|
||||
DO_COMMAND="-d"
|
||||
@ -84,6 +86,9 @@ while getopts 46a:cdi:lnprsV OPT; do
|
||||
n)
|
||||
MD="nameserver"
|
||||
;;
|
||||
O)
|
||||
DO_COMMAND="-O"
|
||||
;;
|
||||
p)
|
||||
MD="prefix"
|
||||
;;
|
||||
@ -116,7 +121,7 @@ if [ "${DO_COMMAND}" = "-c" ]; then
|
||||
HAVE_ROUTE=
|
||||
|
||||
# iterate through possible files for cleanup
|
||||
for MD in nameserver prefix router searchdomain; do
|
||||
for MD in ${FILES}; do
|
||||
for IFC in ${IF} ${IF}:slaac; do
|
||||
FILE="/tmp/${IFC}_${MD}${EX}"
|
||||
if [ ! -f ${FILE} ]; then
|
||||
@ -138,6 +143,30 @@ if [ "${DO_COMMAND}" = "-c" ]; then
|
||||
/sbin/pfctl -i ${IF} -Fs
|
||||
fi
|
||||
|
||||
exit 0
|
||||
elif [ "${DO_COMMAND}" = "-O" ]; then
|
||||
if [ -z "${IF}" ]; then
|
||||
echo "Dumping requires interface option" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# iterate through possible files to print its data (ignore -4/6)
|
||||
for EX in '' v6; do
|
||||
for MD in ${FILES}; do
|
||||
for IFC in ${IF} ${IF}:slaac; do
|
||||
FILE="/tmp/${IFC}_${MD}${EX}"
|
||||
if [ ! -f ${FILE} ]; then
|
||||
continue
|
||||
fi
|
||||
echo -n "${FILE}:"
|
||||
for CONTENT in $(cat ${FILE}); do
|
||||
echo -n " ${CONTENT}"
|
||||
done
|
||||
echo
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
exit 0
|
||||
elif [ "${DO_COMMAND}" = "-l" ]; then
|
||||
if [ -z "${IF}" ]; then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user