detects if running in a docker container, which then requires special treatment of mounts. OpenWrt within Docker is useful for CI testing.
The additional exit(0) treatment in state.c is based on @mikma code[0]. It should fix stopping problems of containers. [0]: https://github.com/mikma/lxd-openwrt/blob/master/patches/procd-master/0003-docker-fix-problem-stopping-container.patch Signed-off-by: Paul Spooren <m...@aparcar.org> --- container.h | 4 +++- state.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/container.h b/container.h index d33fa32..04d63ed 100644 --- a/container.h +++ b/container.h @@ -16,9 +16,11 @@ #include <stdlib.h> #include <stdbool.h> +#include <sys/stat.h> static inline bool is_container() { - return !!getenv("container"); + struct stat s; + return !!getenv("container") || !!stat("/.dockerinit", &s); } #endif diff --git a/state.c b/state.c index ccf4104..ff1734f 100644 --- a/state.c +++ b/state.c @@ -21,6 +21,7 @@ #include <signal.h> #include "procd.h" +#include "container.h" #include "syslog.h" #include "plug/hotplug.h" #include "watchdog.h" @@ -157,6 +158,9 @@ static void state_enter(void) else LOG("- reboot -\n"); + if (is_container()) + exit(0); + /* Allow time for last message to reach serial console, etc */ sleep(1); -- 2.20.1 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel