Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions agent/deploy/netpulse-agent.init
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@ selfheal_binary() {
return 0
}


# (#879) self-heal: tras un sysupgrade /etc sobrevive pero el binario del
# watchdog no: si quedó la entrada de cron del antiguo watchdog, retirarla
# (cron loguearía un comando inexistente cada 2 min).
cleanup_stale_watchdog_cron() {
[ -f /usr/sbin/netpulse-watchdog ] && return 0
crontab -l 2>/dev/null | grep -q netpulse-watchdog || return 0
( crontab -l 2>/dev/null | grep -v netpulse-watchdog ) | crontab - 2>/dev/null || true
logger -t netpulse-agent "watchdog cron huérfano retirado (#879)"
}

start_service() {
cleanup_stale_watchdog_cron
selfheal_binary || logger -t netpulse-agent "self-heal: no se pudo restaurar el binario"
procd_open_instance netpulse-agent
procd_set_param command "$BIN"
Expand Down
12 changes: 12 additions & 0 deletions deploy/openwrt/netpulse-agent/files/netpulse-agent.init
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,19 @@ load_config() {
[ -n "$server_fp" ] && export NETPULSE_SERVER_FP="$server_fp"
}


# (#879) self-heal: tras un sysupgrade /etc sobrevive pero el binario del
# watchdog no: si quedó la entrada de cron del antiguo watchdog, retirarla
# (cron loguearía un comando inexistente cada 2 min).
cleanup_stale_watchdog_cron() {
[ -f /usr/sbin/netpulse-watchdog ] && return 0
crontab -l 2>/dev/null | grep -q netpulse-watchdog || return 0
( crontab -l 2>/dev/null | grep -v netpulse-watchdog ) | crontab - 2>/dev/null || true
logger -t netpulse-agent "watchdog cron huérfano retirado (#879)"
}

start_service() {
cleanup_stale_watchdog_cron
load_config

# Validación mínima
Expand Down
12 changes: 12 additions & 0 deletions install-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,19 @@ selfheal_binary() {
return 0
}


# (#879) self-heal: tras un sysupgrade /etc sobrevive pero el binario del
# watchdog no: si quedó la entrada de cron del antiguo watchdog, retirarla
# (cron loguearía un comando inexistente cada 2 min).
cleanup_stale_watchdog_cron() {
[ -f /usr/sbin/netpulse-watchdog ] && return 0
crontab -l 2>/dev/null | grep -q netpulse-watchdog || return 0
( crontab -l 2>/dev/null | grep -v netpulse-watchdog ) | crontab - 2>/dev/null || true
logger -t netpulse-agent "watchdog cron huérfano retirado (#879)"
}

start_service() {
cleanup_stale_watchdog_cron
selfheal_binary || logger -t netpulse-agent "self-heal: no se pudo restaurar el binario"
procd_open_instance netpulse-agent
procd_set_param command "$BIN"
Expand Down
14 changes: 13 additions & 1 deletion server-go/internal/reinstall/reinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,19 @@ selfheal_binary() {
return 0
}

start_service() {

# (#879) self-heal: tras un sysupgrade /etc sobrevive pero el binario del
# watchdog no: si quedó la entrada de cron del antiguo watchdog, retirarla
# (cron loguearía un comando inexistente cada 2 min).
cleanup_stale_watchdog_cron() {
[ -f /usr/sbin/netpulse-watchdog ] && return 0
crontab -l 2>/dev/null | grep -q netpulse-watchdog || return 0
( crontab -l 2>/dev/null | grep -v netpulse-watchdog ) | crontab - 2>/dev/null || true
logger -t netpulse-agent "watchdog cron huérfano retirado (#879)"
}

start_service() {
cleanup_stale_watchdog_cron
selfheal_binary || logger -t netpulse-agent "self-heal: no se pudo restaurar el binario"
procd_open_instance netpulse-agent
procd_set_param command "$BIN"
Expand Down
17 changes: 17 additions & 0 deletions server-go/internal/reinstall/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,23 @@ func TestScriptSelfHealInit(t *testing.T) {
}
}

// #879: el init entregado por el reinstall auto-repara la entrada de cron del
// antiguo watchdog (tras sysupgrade /etc sobrevive pero el binario no, y cron
// loguearía un comando inexistente cada 2 min).
func TestScriptInitSelfHealsStaleWatchdogCron(t *testing.T) {
s := scriptForTest()
for _, want := range []string{
"cleanup_stale_watchdog_cron()",
"[ -f /usr/sbin/netpulse-watchdog ] && return 0",
"crontab -l 2>/dev/null | grep -q netpulse-watchdog || return 0",
"cleanup_stale_watchdog_cron",
} {
if !strings.Contains(s, want) {
t.Errorf("init sin self-heal #879: falta %q", want)
}
}
}

// #851: el watchdog cron YA NO se instala; el script limpia los restos de
// instalaciones previas que sí lo tenían.
func TestScriptNoWatchdogCron(t *testing.T) {
Expand Down
Loading