diff options
Diffstat (limited to 'src.etc/network/functions')
-rw-r--r-- | src.etc/network/functions | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src.etc/network/functions b/src.etc/network/functions new file mode 100644 index 0000000..b74fb91 --- /dev/null +++ b/src.etc/network/functions @@ -0,0 +1,41 @@ +#!/bin/sh + +case "${0}" in + /etc/network/if-*.d/*) ;; + *) exit 1;; +esac +if [ "x${IFACE}" = 'x' ]; then + exit 1 +fi + +get_iface_opts() +{ + local opts_start_cb="${1}" + local opt_cb="${2}" + local opts_end_cb="${3}" + local script= + local opts= + local opt= + + script="$(printf ' + /^iface[ \\t][ \\t]*%s/,/^[^ \\t]/{ + /^$/q; + s/^[ \\t][ \\t]*//p; + } + ' "${IFACE}")" + + opts="$(sed -n "${script}" /var/run/net-ifaces)" + if [ "x${opts}" = 'x' ]; then + return 0 + fi + + ${opts_start_cb} + while read -r opt; do + ${opt_cb} ${opt} + done <<-EOF + ${opts} + EOF + ${opts_end_cb} + + return 0 +} |