From c066c30908672e2c9052ffbd313c9a342d9764a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Fri, 5 Jul 2024 21:09:34 -0300 Subject: [PATCH 1/6] core: Dockerfile: Install BlueOS cron files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- core/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/Dockerfile b/core/Dockerfile index 16606d941e..2cb2ca166e 100644 --- a/core/Dockerfile +++ b/core/Dockerfile @@ -79,6 +79,8 @@ COPY services /home/pi/services RUN /home/pi/services/install-services.sh COPY start-blueos-core /usr/bin/start-blueos-core COPY run-service.sh /usr/bin/run-service +RUN rm -f /etc/cron.d/* +COPY cron /etc/cron.d # Copy binaries and necessary folders from downloadBinaries to this stage COPY --from=downloadBinaries \ From 2e97b72eaa84fb378772bf6cc169387c3e5295e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Fri, 5 Jul 2024 21:09:50 -0300 Subject: [PATCH 2/6] core: services: install-services: Install cron MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- core/services/install-services.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/services/install-services.sh b/core/services/install-services.sh index 95c39f28a7..3a96571b73 100755 --- a/core/services/install-services.sh +++ b/core/services/install-services.sh @@ -6,13 +6,19 @@ set -e BUILD_PACKAGES=( g++ ) +EXTERNAL_PROGRAMS=( + cron +) + +apt update # Install build packages if not on armv7, which we have all pre-built wheels for if ! { [ "$TARGETARCH" == "arm" ] && [ "$TARGETVARIANT" == "v7" ]; }; then - apt update apt install -y --no-install-recommends ${BUILD_PACKAGES[*]} fi +apt install -y --no-install-recommends ${EXTERNAL_PROGRAMS[*]} + # Wifi service: ## Bind path for wpa mkdir -p /var/run/wpa_supplicant/ From 3d6e8028f746511f6d238565d3a699aee61e6d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Fri, 5 Jul 2024 21:10:29 -0300 Subject: [PATCH 3/6] core: tools: scripts: bootstrap: Install journalctl-vacuum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- core/tools/scripts/bootstrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/core/tools/scripts/bootstrap.sh b/core/tools/scripts/bootstrap.sh index 2b99f90386..2b69d3a6b7 100755 --- a/core/tools/scripts/bootstrap.sh +++ b/core/tools/scripts/bootstrap.sh @@ -5,3 +5,4 @@ set -e SCRIPTS_PATH="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; cp $SCRIPTS_PATH/red-pill /usr/bin/ +cp $SCRIPTS_PATH/journalctl-vacuum /usr/bin/ From fc98986ac73aef60db75611db5c3277d846014ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Fri, 5 Jul 2024 21:10:52 -0300 Subject: [PATCH 4/6] core: tools: scripts: Add journalctl-vacuum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- core/tools/scripts/journalctl-vacuum | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 core/tools/scripts/journalctl-vacuum diff --git a/core/tools/scripts/journalctl-vacuum b/core/tools/scripts/journalctl-vacuum new file mode 100755 index 0000000000..afac02f70c --- /dev/null +++ b/core/tools/scripts/journalctl-vacuum @@ -0,0 +1,8 @@ +#!/usr/local/bin/python +from commonwealth.utils.commands import run_command +from loguru import logger + +if __name__ == "__main__": + ret = run_command("sudo journalctl --vacuum-size=100M", False) + logger.add("/tmp/journal-vacuum.log") + logger.debug(f"Command output: {ret}") From b0ab5aa392f0c163f4fef8d48e377a5ffad279a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Fri, 5 Jul 2024 21:11:10 -0300 Subject: [PATCH 5/6] core: cron: Add first version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- core/cron/waste-collector | 1 + 1 file changed, 1 insertion(+) create mode 100644 core/cron/waste-collector diff --git a/core/cron/waste-collector b/core/cron/waste-collector new file mode 100644 index 0000000000..96193d6650 --- /dev/null +++ b/core/cron/waste-collector @@ -0,0 +1 @@ +0 */4 * * * root journalctl-vacuum # Run every 4 hours \ No newline at end of file From a6c2048b46d82c55dd06265d47354f0304a7c2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Fri, 5 Jul 2024 21:10:00 -0300 Subject: [PATCH 6/6] core: start-blueos-core: Start cron and journalctl-vacuum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- core/start-blueos-core | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/start-blueos-core b/core/start-blueos-core index aa6a0190ef..fd3614a873 100755 --- a/core/start-blueos-core +++ b/core/start-blueos-core @@ -93,6 +93,9 @@ mkdir -p /usr/blueos/userdata/settings find /usr/blueos -type d -exec chmod a+rw {} \; find /usr/blueos -type f -exec chmod a+rw {} \; +cron || echo "Failed to start cron service!" +journalctl-vacuum || echo "Failed to run journalctl-vacuum service!" + # These services have priority because they do the fundamental for the vehicle to work, # and by initializing them first we reduce the time users have to wait to control the vehicle. # From tests with QGC and Pi3, the reboot time was ~1min42s when not using this strategy,