strongswan: simplify indentation

Allow passing multiple config lines with the same indent level.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
This commit is contained in:
Philip Prindeville 2023-03-26 13:52:55 -06:00
parent 03eab9b63b
commit 216b6b61a8

View file

@ -63,9 +63,12 @@ file_reset() {
xappend() {
local file="$1"
shift
local indent="$2"
shift 2
echo "$@" >> "$file"
for cmd in "$@"; do
echo "$indent$cmd" >> "$file"
done
}
swan_reset() {
@ -77,23 +80,23 @@ swan_xappend() {
}
swan_xappend0() {
swan_xappend "$@"
swan_xappend "" "$@"
}
swan_xappend1() {
swan_xappend " ""$@"
swan_xappend " " "$@"
}
swan_xappend2() {
swan_xappend " ""$@"
swan_xappend " " "$@"
}
swan_xappend3() {
swan_xappend " ""$@"
swan_xappend " " "$@"
}
swan_xappend4() {
swan_xappend " ""$@"
swan_xappend " " "$@"
}
swanctl_reset() {
@ -105,23 +108,23 @@ swanctl_xappend() {
}
swanctl_xappend0() {
swanctl_xappend "$@"
swanctl_xappend "" "$@"
}
swanctl_xappend1() {
swanctl_xappend " ""$@"
swanctl_xappend " " "$@"
}
swanctl_xappend2() {
swanctl_xappend " ""$@"
swanctl_xappend " " "$@"
}
swanctl_xappend3() {
swanctl_xappend " ""$@"
swanctl_xappend " " "$@"
}
swanctl_xappend4() {
swanctl_xappend " ""$@"
swanctl_xappend " " "$@"
}
warning() {
@ -335,7 +338,7 @@ config_child() {
[ $ipcomp -eq 1 ] && swanctl_xappend4 "ipcomp = 1"
[ -n "$interface" ] && swanctl_xappend4 "interface = $interface"
[ -n "$priority" ] && swanctl_xappend4 "priority = $priority"
[ -n "$if_id" ] && { swanctl_xappend4 "if_id_in = $if_id" ; swanctl_xappend4 "if_id_out = $if_id" ; }
[ -n "$if_id" ] && swanctl_xappend4 "if_id_in = $if_id" "if_id_out = $if_id"
[ -n "$startaction" -a "$startaction" != "none" ] && swanctl_xappend4 "start_action = $startaction"
[ -n "$closeaction" -a "$closeaction" != "none" ] && swanctl_xappend4 "close_action = $closeaction"
swanctl_xappend4 "esp_proposals = $esp_proposal"