Skip to content

Commit

Permalink
mwan3: treat SIGHUP as non-error
Browse files Browse the repository at this point in the history
A return code of 129 means that the script has been killed by SIGHUP,
expected to abort an alert in case of mwan3 restart
Every other code is treated as error and the error message is logged.
  • Loading branch information
filippocarletti committed Jan 30, 2025
1 parent 70a435b commit d5b6950
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/ns-plug/files/mwan-hooks
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

failed_count=0

# Execute all mwan scrips
# Execute all mwan scripts
for f in $(find /usr/libexec/mwan-hooks/ -type f -executable)
do
# Execute the script
$f
# Execute the script and capture the output:
# avoid unwanted output if the script is terminated with a SIGHUP
output=$($f 2>&1)
exit_code=$?
if [ $exit_code -gt 0 ]; then
if [[ $exit_code -gt 0 && $exit_code != 129 ]]; then
((failed_count++))
logger -t mwan3-hook "Script $f failed with exit code $exit_code"
logger -t mwan3-hook "Script $f returned $exit_code: $output"
fi
done

Expand Down

0 comments on commit d5b6950

Please sign in to comment.