Migrate Traccar config out of Home Assistant config folder

This commit is contained in:
Franck Nijhof 2023-11-10 22:10:35 +01:00
parent 1a6c19c124
commit c18e0e6da3
No known key found for this signature in database
GPG key ID: D62583BA8AB11CA3
3 changed files with 11 additions and 2 deletions

View file

@ -106,7 +106,7 @@ been done to reduce the number of open ports the add-on would create.
By default, only the OsmAnd protocol (used by the Traccar Apps) and the API
are enabled. If you want more protocols, you can do so, by adding entries
to your `/config/traccar.xml` file.
to your `traccar.xml` file in the add-on configuration folder.
A list if all entries can be found here:

View file

@ -18,7 +18,8 @@ ports:
ports_description:
80/tcp: Web interface
map:
- config:rw
- addon_config:rw
- homeassistant_config:rw
- ssl
services:
- mysql:want

View file

@ -8,6 +8,14 @@ declare password
declare port
declare username
# Migrate add-on data from the Home Assistant config folder,
# to the add-on configuration folder.
if ! bashio::fs.directory_exists '/config/traccar.xml' \
&& bashio::fs.file_exists '/homeassistant/traccar.xml'; then
mv /homeassistant/traccar.xml /config/traccar.xml \
|| bashio::exit.nok "Failed to migrate Traccar configuration"
fi
if ! bashio::fs.file_exists "/config/traccar.xml"; then
cp /etc/traccar/traccar.xml /config/traccar.xml
else