From 4fd103f722fcadcecc5df7fa4d9023b97ace0187 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Fri, 31 Mar 2023 20:01:13 +0200 Subject: [PATCH] Only run configure if anything changed --- cmd/app/main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/app/main.go b/cmd/app/main.go index 35c5a2c..766fc30 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -123,9 +123,13 @@ func main() { } } - err = client.ConfigureDevice(iface, wgConfig) - if(err != nil){ - logger.Error.Fatalf("Error configuring wg-device '%s': %s", iface, err) + if(len(wgConfig.Peers) == 0){ + logger.Info.Println("No changes, skipping") + } else { + err = client.ConfigureDevice(iface, wgConfig) + if(err != nil){ + logger.Error.Fatalf("Error configuring wg-device '%s': %s", iface, err) + } } // Sleep for 300 seconds before running the loop again