From 6725b3f7dafc0e9d16f69be71cd46a637fef845a Mon Sep 17 00:00:00 2001 From: Issac Date: Mon, 10 Feb 2020 14:52:34 +0200 Subject: [PATCH] remove lastboot before supervisor startup (#1065) * Add devcontainer (generic add-on devcontainer also available at https://github.com/issacg/hassio-addon-devcontainer) * remove example code (https://github.com/home-assistant/hassio-addons/pull/1040#discussion_r374373037) * Run start_hassio.sh from inside .devcontainer (https://github.com/home-assistant/hassio-addons/pull/1040#discussion_r374373323) * Revert "Fix HA container" This reverts commit 7062117d4672b1a3e1e570bc59f4dffbffb99e9a. * Fix lastboot --- .devcontainer/Dockerfile | 1 + .devcontainer/start_hassio.sh | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d9c8870..76fab8b 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -19,6 +19,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ software-properties-common \ gpg-agent \ git \ + jq \ sudo \ && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - \ && add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \ diff --git a/.devcontainer/start_hassio.sh b/.devcontainer/start_hassio.sh index eeb2800..48abeb8 100644 --- a/.devcontainer/start_hassio.sh +++ b/.devcontainer/start_hassio.sh @@ -68,10 +68,14 @@ function cleanup_hass_data() { function cleanup_docker() { echo "Cleaning up stopped containers..." docker rm $(docker ps -a -q) +} - # Clean homeassistant instance - if docker rm -f homeassistant 2> /dev/null; then - echo "Cleanup HomeAssistant instance" +function cleanup_lastboot() { + if [[ -f /workspaces/test_hassio/config.json ]]; then + echo "Cleaning up last boot" + cp /workspaces/test_hassio/config.json /tmp/config.json + jq -rM 'del(.last_boot)' /tmp/config.json > /workspaces/test_hassio/config.json + rm /tmp/config.json fi } @@ -102,6 +106,7 @@ case "$1" in start_docker trap "stop_docker" ERR cleanup_docker || true + cleanup_lastboot || true install run_supervisor stop_docker;;