DHCPInfo/utils/shared-networks.sh

19 lines
596 B
Bash
Raw Normal View History

2023-11-12 21:38:07 +00:00
#!/bin/bash
get_shared_network_declarations () {
2023-11-12 23:08:54 +00:00
local -n HASH_TABLE="${1:?"get_shared_network_declarations: Hash table variable not passed into function"}"
local CONTENT="${2:?"get_shared_network_declarations: Content was not provided"}"
local -a SECTIONS
2023-11-12 21:38:07 +00:00
2023-11-12 23:08:54 +00:00
local SECTION_CONTENT SECTION_NAME
2023-11-12 21:38:07 +00:00
2023-11-12 23:08:54 +00:00
get_sections "$SHARED_NETWORK_BEGIN_REGEX" SECTIONS "$CONTENT"
2023-11-12 21:38:07 +00:00
2023-11-12 23:08:54 +00:00
for i in ${!SECTIONS[@]}; do
SECTION_CONTENT="${SECTIONS[$i]}"
SECTION_NAME=`grep -Eo $SHARED_NETWORK_BEGIN_REGEX <<< "$SECTION_CONTENT" | awk '{ print $2 }' | tr -d \" `
HASH_TABLE[$SECTION_NAME]="$SECTION_CONTENT"
done
2023-11-12 21:38:07 +00:00
}