Search code examples
linuxbashdbuswatchdog

Monitoring rauc install process using D-Bus


I am using rauc to install updates on my linux device. I want to use a watchdog (already installed on the device in WATCHDOG_DEVICE) to monitor the rauc install process to make sure that everything is running smoothly. But it looks like the keepWatchdogAlive function is not called. I am also not sure if my DBUS variables are set correct and if the dbus-monitor call is correct.

This is my relevant code:

DBUS_INTERFACE="de.pengutronix.rauc.Installer"
DBUS_MEMBER="PropertiesChanged"

keepWatchdogAlive()
{
  echo "1" > $WATCHDOG_DEVICE
  echo "Keep Watchdog alive"
}

monitor_dbus() {
  while true; do
    stdbuf -oL dbus-monitor --system "type='signal',interface='$DBUS_INTERFACE',member='$DBUS_MEMBER'" |
    while read -r line; do
      if echo "$line" | grep -q "Progress"; then
          keepWatchdogAlive
      fi
    done
  done
}

echo "Starting Watchdog ... "
watchdog -t 10 $WATCHDOG_DEVICE

echo "Starting D-Bus monitor. Waiting for $DBUS_MEMBER signals on $DBUS_INTERFACE ... "
monitor_dbus &
DBUS_MONITOR_PID=$!

echo "Starting Update Agent script ... "
if [ -d "$RAUC_BUNDLE_DIR" ]; then
  if [ -n "$(ls -A "$RAUC_BUNDLE_DIR")" ]; then
    for bundle in "$RAUC_BUNDLE_DIR"/*
    do
      rauc install "$bundle"
    done
  else
    echo "No rauc bundles found in $RAUC_BUNDLE_DIR"
  fi
else
  echo "Directory $RAUC_BUNDLE_DIR does not exist."
fi

When I call dbus-monitor on my command line, it says only this the whole time:

sig 1731876918.081532 2 org.freedesktop.DBus :1.1 /org/freedesktop/DBus org.freedesktop.DBus NameAcquired
sig 1731876918.081599 4 org.freedesktop.DBus :1.1 /org/freedesktop/DBus org.freedesktop.DBus NameLost

The relevant rauc documentation does not have any examples https://rauc.readthedocs.io/en/latest/using.html#processing-progress-data https://rauc.readthedocs.io/en/latest/reference.html#the-progress-property


Solution

  • I found the bug. One of my variables should actually be:

    DBUS_INTERFACE="org.freedesktop.DBus.Properties"