add --keep-confdir

This commit is contained in:
garywill 2025-07-27 12:55:28 +08:00
parent cfeadeb3bd
commit 3900871977
1 changed files with 8 additions and 1 deletions

View File

@ -126,6 +126,8 @@ Options:
Instance managing:
--daemon Run in background
--keep-confdir Don't delete the temporary config dir after exit
-l, --list-running Show running instances
--lc, --list-clients <id|interface>
List clients of an instance. Or list neighbors of
@ -232,6 +234,7 @@ define_global_variables(){
NM_PID=
FIREWALLD_PID=
TMP_FIREWALLD_ZONE=
KEEP_CONFDIR=
}
parse_user_options(){
@ -508,6 +511,10 @@ parse_user_options(){
LIST_CLIENTS_ID="$1"
shift
;;
--keep-confdir)
shift
KEEP_CONFDIR=1
;;
*)
echo "Invalid parameter: $1" 1>&2
@ -1330,7 +1337,7 @@ _cleanup() {
ip addr flush "${SUBNET_IFACE}"
rm -rf "$CONFDIR"
[[ ! "$KEEP_CONFDIR" -eq 1 ]] && rm -rf "$CONFDIR"
ip link set down dev "${SUBNET_IFACE}"