Skip to content

Commit 279c0e1

Browse files
giulio93Your Namelucarin91
authored
Restart avahi with start&stop
Co-authored-by: Your Name <youremail@example.com> Co-authored-by: Luca Rinaldi <lucarin@protonmail.com>
1 parent 6780894 commit 279c0e1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
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, /usr/bin/systemctl restart 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

pkg/board/board.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,14 @@ func SetCustomName(ctx context.Context, conn remote.RemoteConn, name string) err
252252
return fmt.Errorf("failed get board status: %w", err)
253253
}
254254
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)
255+
cmds := [][]string{
256+
{"sudo", "systemctl", "stop", "avahi-daemon"},
257+
{"sudo", "systemctl", "start", "avahi-daemon"},
258+
}
259+
for _, cmd := range cmds {
260+
if out, err := conn.GetCmd(cmd[0], cmd[1:]...).Output(ctx); err != nil {
261+
return fmt.Errorf("failed to run cmd %q: %w: %s", strings.Join(cmd, " "), err, string(out))
262+
}
259263
}
260264
}
261265

0 commit comments

Comments
 (0)