Skip to content

fix: refactors startup scripts to work with the new configuration#357

Open
MrFinchMkV wants to merge 2 commits intohassio-addons:mainfrom
MrFinchMkV:fix/startup_v6
Open

fix: refactors startup scripts to work with the new configuration#357
MrFinchMkV wants to merge 2 commits intohassio-addons:mainfrom
MrFinchMkV:fix/startup_v6

Conversation

@MrFinchMkV
Copy link
Copy Markdown

@MrFinchMkV MrFinchMkV commented Jan 5, 2026

Proposed Changes

Hey community,

Problem: The addon fails to start with current master traccar v6.10.
Finding: In v6.2 the configuration directive 'config.default' was removed.

Last working version with the current traccar config is 6.1.

To get version 6.2 up and running we need to remove 'config.default' from the configuration.
I tried to include the hassio.xml in order to keep the current workflow.
Sadly I wasn't able to archive it, so removed the file and migrated it's content into traccar.xml.

I was now able to start Traccar until version 6.8.
In version 6.9 the web.path changed from .modern to .web. As it was hardcoded in the config it failed.
Removing it fixed it.
As cleanup I removed all settings that had the same value as the default.

Some of my thoughts

Unremoved garbage backupfile

I know that my proposed changed will create a 'garbage' backup file.
But it was the best I could come up with to preserve the current configuration should it contain custom parameter.

Secrets in config

I'm aware that secrets are written to the config.
If the user and password combination is not uniq to the traccar addon, but a generic one my solution might need an improvement. But as I said - I failed to seperate it :(

Related Issues

Can we update to latest version 6.5 #334

Summary by CodeRabbit

  • New Features

    • Automatic configuration backup-and-migrate to preserve settings during updates.
  • Improvements

    • Improved MySQL database configuration for better compatibility.
    • Updated default configuration layout with new web, logging, geocoding, and notification options.
    • Expanded and clarified available port configuration options.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 5, 2026

Walkthrough

This PR replaces the legacy hassio.xml with traccar.xml, updates init scripts to back up and migrate existing configs, and changes MySQL XML updates to directly modify existing /properties/entry[@key=...] nodes (JDBC URL, driver, user, password) in traccar.xml.

Changes

Cohort / File(s) Summary
Init scripts
traccar/rootfs/etc/cont-init.d/mysql.sh, traccar/rootfs/etc/cont-init.d/traccar.sh
mysql.sh now targets /etc/traccar/traccar.xml (not hassio.xml) and updates database entries directly via xmlstarlet (database.driver, database.url, database.user, database.password). traccar.sh adds a one-time backup-and-migrate step: if /config/traccar.v5.12.xml missing, back up /config/traccar.xml/config/traccar.v5.12.xml and copy /etc/traccar/traccar.xml/config/traccar.xml, with explicit error handling.
Configuration files
traccar/rootfs/etc/traccar/hassio.xml (removed), traccar/rootfs/etc/traccar/traccar.xml
Removed hassio.xml. Added/updated traccar.xml containing default entries for web (address, port, persistSession), geocoder, logger, notificator types, database credentials (driver, URL, user, password), and osmand.port plus expanded example ports block. JDBC URL literals use unescaped & in the new updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibble through configs, tidy and spry,
Backup a copy, then watch old files fly,
Drivers and URLs hopped into place,
XML fields updated with nimble grace,
A rabbit's leap — migration done! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: refactoring startup scripts to work with new Traccar v6.x configuration requirements after config.default removal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c0f475 and e26209c.

📒 Files selected for processing (1)
  • traccar/rootfs/etc/cont-init.d/traccar.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • traccar/rootfs/etc/cont-init.d/traccar.sh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Fix all issues with AI Agents 🤖
In @traccar/rootfs/etc/cont-init.d/traccar.sh:
- Around line 19-26: The backup/migration block assumes /config/traccar.xml
exists; add a check using bashio::fs.file_exists to only run mv
/config/traccar.xml -> /config/traccar.v5.12.xml when the source exists,
otherwise skip the mv and proceed to copy the default /etc/traccar/traccar.xml
into /config/traccar.xml; keep the existing error handling (bashio::exit.nok)
for the mv and cp commands and use the same paths and functions
(bashio::fs.file_exists, mv, cp) so the script won't exit with nok on fresh
installs that lack /config/traccar.xml.
🧹 Nitpick comments (1)
traccar/rootfs/etc/traccar/traccar.xml (1)

33-34: Consider noting the duplicate in the commented examples.

osmand.port is enabled here and also appears in the commented examples at line 92. This is harmless but could confuse users editing the file. A brief inline comment like <!-- already enabled above --> at line 92 would help clarity.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd2953d and 5c0f475.

📒 Files selected for processing (4)
  • traccar/rootfs/etc/cont-init.d/mysql.sh
  • traccar/rootfs/etc/cont-init.d/traccar.sh
  • traccar/rootfs/etc/traccar/hassio.xml
  • traccar/rootfs/etc/traccar/traccar.xml
💤 Files with no reviewable changes (1)
  • traccar/rootfs/etc/traccar/hassio.xml
🔇 Additional comments (3)
traccar/rootfs/etc/traccar/traccar.xml (1)

6-23: LGTM!

The default configuration entries are well-structured. Binding web.address to 127.0.0.1 is appropriate for the add-on running behind a proxy, and the H2 database defaults provide a working out-of-box experience.

traccar/rootfs/etc/cont-init.d/mysql.sh (2)

24-38: LGTM - xmlstarlet usage is correct.

The -u (update) operations work correctly with the new traccar.xml template that includes placeholder entries. Note that if users have removed these entries from their config, the updates will silently do nothing - this is probably acceptable given the migration workflow creates a fresh config.


6-6: Correct the database configuration target for existing installations.

This script modifies /etc/traccar/traccar.xml (the template), which works for new installations since traccar.sh copies the template to /config/traccar.xml on first run. However, for existing installations, traccar.sh skips the copy step (lines 30–42) and only manages the database lock. This means database configuration updates from mysql.sh won't reach the active configuration file at /config/traccar.xml.

Either modify /config/traccar.xml directly in this script, or ensure the template is re-copied for existing installations if dynamic database updates are needed.

Likely an incorrect or invalid review comment.

Comment thread traccar/rootfs/etc/cont-init.d/traccar.sh
@jrb80
Copy link
Copy Markdown

jrb80 commented Feb 4, 2026

@frenck can you review and approve this change?

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 7, 2026

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Mar 7, 2026
@jrb80
Copy link
Copy Markdown

jrb80 commented Mar 7, 2026

I hope this pull gets merged!

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Mar 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Apr 7, 2026
@jrb80
Copy link
Copy Markdown

jrb80 commented Apr 7, 2026

Bump

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants