feat: add ip and mac variables to wake/shutdown commands

This commit is contained in:
Maxi Quoß
2025-10-19 22:42:27 +02:00
parent 9e8983d961
commit c736561fab
2 changed files with 8 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"os/exec"
"runtime"
"strings"
"time"
"github.com/pocketbase/pocketbase/core"
@@ -29,6 +30,9 @@ func ShutdownDevice(device *core.Record) error {
shell_arg = "-c"
}
shutdown_cmd = strings.ReplaceAll(shutdown_cmd, "{{ DEVICE_IP }}", device.GetString("ip"))
shutdown_cmd = strings.ReplaceAll(shutdown_cmd, "{{ DEVICE_MAC }}", device.GetString("mac"))
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"os/exec"
"runtime"
"strings"
"time"
"github.com/pocketbase/pocketbase/core"
@@ -32,6 +33,9 @@ func WakeDevice(device *core.Record) error {
shell_arg = "-c"
}
wake_cmd = strings.ReplaceAll(wake_cmd, "{{ DEVICE_IP }}", device.GetString("ip"))
wake_cmd = strings.ReplaceAll(wake_cmd, "{{ DEVICE_MAC }}", device.GetString("mac"))
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()