From 3d8f727fca9e851640aaee7360a64e0d51d76856 Mon Sep 17 00:00:00 2001 From: Alex Harvey Date: Mon, 25 Sep 2023 09:42:05 +1000 Subject: [PATCH] Update gen_params.sh A refactor in firewall 7.0.0 meant changes needed in the gen_params.sh script. --- gen_params.sh | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/gen_params.sh b/gen_params.sh index 39b9307..e1dd3d0 100644 --- a/gen_params.sh +++ b/gen_params.sh @@ -48,7 +48,7 @@ EOF } firewall_lib() { - cat "$path_to_firewall"'/lib/puppet/type/firewall.rb' + cat "$path_to_firewall"'/lib/puppet/provider/firewall/firewall.rb' } sort_cols() { @@ -57,14 +57,10 @@ sort_cols() { first_transform() { firewall_lib \ - | gsed -nE ' - /^ new/ { - /(property|param)/ { - /:name/! { - s/^ newp.*\(:([^,\)]*).*/$\1 = undef,/p - } - } - } + | awk ' + /\$resource_map = {/ { flag=1; next } + /^ }/ { flag=0 } + flag && /:/ { split($0, arr, ":"); gsub(/^[ \t]+|[ \t]+$/, "", arr[1]); print "$" arr[1] " = undef," } ' | sort_cols | gsed ' s/^/ / s/ = /=/ @@ -73,14 +69,10 @@ first_transform() { second_transform() { firewall_lib \ - | gsed -nE ' - /^ new/ { - /(property|param)/ { - /:name/! { - s/^ newp.*\(:([^,\)]*).*/\1 => $\1,/p - } - } - } + | awk ' + /\$resource_map = {/ { flag=1; next } + /^ }/ { flag=0 } + flag && /:/ { split($0, arr, ":"); gsub(/^[ \t]+|[ \t]+$/, "", arr[1]); print arr[1] " => $" arr[1] "," } ' | sort_cols | gsed ' s/^/ / s/ => /=>/