Skip to content

Commit 147edf8

Browse files
giulio93Your Name
andauthored
Changing the board name should also restart the avahi-daemon
Co-authored-by: Your Name <youremail@example.com>
1 parent 10dc1ac commit 147edf8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
arduino ALL=(ALL) NOPASSWD: /usr/sbin/dpkg-reconfigure openssh-server, /usr/bin/systemctl enable ssh, /usr/bin/systemctl start ssh, /usr/bin/systemctl disable ssh, /usr/bin/systemctl stop ssh, /usr/bin/systemctl disable avahi-daemon, /usr/bin/systemctl stop avahi-daemon, /usr/bin/systemctl enable avahi-daemon, /usr/bin/systemctl start avahi-daemon
1+
arduino ALL=(ALL) NOPASSWD: /usr/sbin/dpkg-reconfigure openssh-server, /usr/bin/systemctl enable ssh, /usr/bin/systemctl start ssh, /usr/bin/systemctl disable ssh, /usr/bin/systemctl stop ssh, /usr/bin/systemctl disable avahi-daemon, /usr/bin/systemctl stop avahi-daemon, /usr/bin/systemctl enable avahi-daemon, /usr/bin/systemctl start avahi-daemon, /usr/bin/systemctl restart avahi-daemon

pkg/board/board.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,21 @@ func SetCustomName(ctx context.Context, conn remote.RemoteConn, name string) err
244244
Run(ctx)
245245
if err != nil {
246246
return fmt.Errorf("failed to set board name: %w", err)
247+
248+
}
249+
250+
isEnable, err := NetworkModeStatus(ctx, conn)
251+
if err != nil {
252+
return fmt.Errorf("failed get board status: %w", err)
247253
}
254+
if isEnable {
255+
err = conn.GetCmd("sudo", "systemctl", "restart", "avahi-daemon").
256+
Run(ctx)
257+
if err != nil {
258+
return fmt.Errorf("failed to restart avahi-daemon: %w", err)
259+
}
260+
}
261+
248262
return nil
249263
}
250264

0 commit comments

Comments
 (0)