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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ The version lives in `CERBERUS_VERSION` in `src/cerberus.c` (`MAJOR.MINOR.PATCH`
published only as the [`latest`](https://github.com/OpenIPC/cerberus/releases/latest) release
(see the README); this file is the change history, newest first.

## 0.3.3 — 2026-11-12

- The coordinator's `EnableMotion` command switches majestic's own motion detector on
(`cli -s .motionDetect.enabled true`, `cli -s .system.plugins true`) and restarts majestic
(`/etc/init.d/S95majestic restart`, or SIGHUP where the firmware has no such script). Until now
the cloud's "look for people" switch did nothing on a camera whose detector had not been turned
on by hand in its web interface. Switching it off stays where it was: in the web interface.

## 0.3.2 — 2026-10-28

- `cerberus status` prints the device's public key and its fingerprint — the same eight groups the
Expand Down
34 changes: 33 additions & 1 deletion src/cerberus.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

/* The version of every build, release builds included (#32); `make VERSION=...` overrides it for a test build. */
#ifndef CERBERUS_VERSION
#define CERBERUS_VERSION "0.3.2"
#define CERBERUS_VERSION "0.3.3"
#endif

/* Where the errors are decoded. Printed after every fatal one: the reader is on a camera
Expand Down Expand Up @@ -2105,6 +2105,36 @@ static void do_reboot(void)
warn_("reboot failed — no usable reboot binary");
}

/*
* EnableMotion: majestic's own motion detector on, so that the hook it runs on motion — the only
* thing that wakes the event path — fires at all. Without it the cloud's "look for people" switch
* does nothing and nobody can tell why. There is no counterpart to switch it off: that is done in
* the camera's web interface, where it was always done.
*
* Both keys go through `cli`, majestic's own config tool, rather than an edit of majestic.yaml by
* hand: the file's layout is majestic's business. A restart then makes majestic read them; where
* the firmware has no init script by that name, SIGHUP — what the web interface sends after saving.
*/
static void enable_motion(void)
{
char *detector[] = { "cli", "-s", ".motionDetect.enabled", "true", NULL };
char *plugins[] = { "cli", "-s", ".system.plugins", "true", NULL };
char *restart[] = { "/etc/init.d/S95majestic", "restart", NULL };
char *reload[] = { "killall", "-1", "majestic", NULL };

if (run(detector, NULL, 0) != 0 || run(plugins, NULL, 0) != 0) {
warn_("EnableMotion: `cli -s` failed — is majestic on this firmware?");
return;
}
if (run(restart, NULL, 0) != 0 && run(reload, NULL, 0) != 0) {
warn_("EnableMotion: the detector is on in majestic's config, but majestic could not be restarted"
" — it takes effect on majestic's next start");
return;
}
note("motion detection switched on in majestic%s",
g_cfg.events ? "" : " (motion events are off in this agent, so nothing will reach the cloud)");
}

/*
* Применяет NodeDirective из ответа на heartbeat.
*
Expand Down Expand Up @@ -2164,6 +2194,8 @@ static void apply_directive(const char *json)
do_reboot();
else if (!strcmp(command, "Restart"))
self_restart();
else if (!strcmp(command, "EnableMotion"))
enable_motion();
else if (strcmp(command, "None") != 0)
warn_("unknown command '%s' from the coordinator — ignoring", command);
}
Expand Down
13 changes: 13 additions & 0 deletions tests/suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,19 @@ ctl command '{"command":"Reboot"}'
runfor 7 reboot.log PATH="$T/bin:$PATH"
check "Reboot: syncs and calls reboot" "$(yes_if test -e $T/rebooted)" "yes"

printf '#!/bin/sh
echo "$*" >>%s/cli.calls
' $T >$T/bin/cli && chmod +x $T/bin/cli
printf '#!/bin/sh
echo "$*" >>%s/killall.calls
' $T >$T/bin/killall && chmod +x $T/bin/killall
ctl command '{"command":"EnableMotion"}'
runfor 7 motion-on.log PATH="$T/bin:$PATH"
check "EnableMotion: both majestic keys through cli" "$(tr '
' ';' <$T/cli.calls)" "-s .motionDetect.enabled true;-s .system.plugins true;"
check "and majestic is told to re-read them" "$(cat $T/killall.calls)" "-1 majestic"
check "and says so" "$(yes_if grep -q 'motion detection switched on in majestic' motion-on.log)" "yes"

ctl command '{"command":"SelfDestruct"}'
runfor 7 unknown.log
check "an unknown command is ignored, loudly" "$(yes_if grep -q "unknown command 'SelfDestruct'" unknown.log)" "yes"
Expand Down
Loading