From d1f780f5037e48165b57d67b1b7a8335f1a8174a Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 1 Mar 2020 02:24:27 +0100 Subject: [PATCH] :ambulance: Make sure the database isn't locked on startup --- traccar/rootfs/etc/cont-init.d/traccar.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/traccar/rootfs/etc/cont-init.d/traccar.sh b/traccar/rootfs/etc/cont-init.d/traccar.sh index 3e75ef6..b81175a 100644 --- a/traccar/rootfs/etc/cont-init.d/traccar.sh +++ b/traccar/rootfs/etc/cont-init.d/traccar.sh @@ -3,6 +3,24 @@ # Home Assistant Community Add-on: Traccar # Ensures the user configuration file is present # ============================================================================== +declare host +declare password +declare port +declare username + if ! bashio::fs.file_exists "/config/traccar.xml"; then cp /etc/traccar/traccar.xml /config/traccar.xml +else + # Existing installation + if bashio::services.available "mysql"; then + # Make sure the database isn't locked + host=$(bashio::services "mysql" "host") + password=$(bashio::services "mysql" "password") + port=$(bashio::services "mysql" "port") + username=$(bashio::services "mysql" "username") + + echo "UPDATE DATABASECHANGELOGLOCK SET locked=0;" \ + | mysql -h "${host}" -P "${port}" -u "${username}" -p"${password}" \ + traccar + fi fi