Skip to content

Databasus: move .env to filesystem root so service starts correctly#14252

Merged
CrazyWolf13 merged 4 commits intomainfrom
copilot/fix-databasus-start-issue
May 4, 2026
Merged

Databasus: move .env to filesystem root so service starts correctly#14252
CrazyWolf13 merged 4 commits intomainfrom
copilot/fix-databasus-start-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 4, 2026

The Databasus service exits immediately after install because config.go traverses up from the working directory looking for go.mod, then loads .env from the parent of wherever go.mod is found. Since go.mod lives in /opt/databasus/backend/ but the service WorkingDirectory is /opt/databasus/, the traversal reaches / and attempts to load /.env — which was never created.

✍️ Description

install/databasus-install.sh

  • Write .env to /.env instead of /opt/databasus/.env
  • Drop chown postgres:postgres (service runs as root); keep chmod 600
  • Set EnvironmentFile=/.env in the systemd unit

ct/databasus.sh (update function)

  • Backup/restore /.env instead of /opt/databasus/.env
  • Add chmod 600 on the backup file to prevent secrets exposure during update
  • Patch the existing systemd service file to EnvironmentFile=/.env and reload the daemon, so containers updated from older installs also get the corrected path without a full reinstall
  • Guard the service file patch with a grep check so it only runs when EnvironmentFile=/.env is not already present, avoiding redundant writes and daemon reloads on already-updated containers

Placing .env at /.env is consistent with the app's traversal logic and keeps it outside /opt/databasus/, so it survives CLEAN_INSTALL=1 updates without needing special backup/restore handling. The /databasus-data/ paths already at filesystem root are likewise preserved.

✅ Prerequisites (X in brackets)

  • Self-review completed – Code follows project standards.
  • Tested thoroughly – Changes work as expected.
  • No security risks – No hardcoded secrets, unnecessary privilege escalations, or permission issues.

🛠️ Type of Change (X in brackets)

  • 🐞 Bug fix – Resolves an issue without breaking functionality.
  • New feature – Adds new, non-breaking functionality.
  • 💥 Breaking change – Alters existing functionality in a way that may require updates.
  • 🆕 New script – A fully functional and tested script or script set.
  • 🌍 Website update – Changes to script metadata (PocketBase/website data).
  • 🔧 Refactoring / Code Cleanup – Improves readability or maintainability without changing functionality.
  • 📝 Documentation update – Changes to README, AppName.md, CONTRIBUTING.md, or other docs.

Copilot AI linked an issue May 4, 2026 that may be closed by this pull request
2 tasks
Copilot AI changed the title [WIP] Fix databasus service failed to start fix(databasus): move .env to filesystem root so service starts correctly May 4, 2026
Copilot AI requested a review from MickLesk May 4, 2026 18:58
@MickLesk
Copy link
Copy Markdown
Member

MickLesk commented May 4, 2026

@copilot Update of Service in update_script is missing

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 4, 2026

@copilot Update of Service in update_script is missing

Added in commit 32bee2c — the update_script now patches the existing service file with sed -i 's|EnvironmentFile=.*|EnvironmentFile=/.env|' and reloads the daemon, so containers updated from older installs also get the corrected path.

@MickLesk
Copy link
Copy Markdown
Member

MickLesk commented May 4, 2026

@copilot grep If Service already updated or Not...

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 4, 2026

@copilot grep If Service already updated or Not...

Done in dc70bc1 — the patch is now wrapped in if ! grep -q "EnvironmentFile=/.env" /etc/systemd/system/databasus.service; then ... fi, so it only runs when the service file hasn't already been updated.

@MickLesk MickLesk changed the title fix(databasus): move .env to filesystem root so service starts correctly Databasus: move .env to filesystem root so service starts correctly May 4, 2026
@github-actions github-actions Bot added bugfix update script A change that updates a script labels May 4, 2026
@MickLesk MickLesk marked this pull request as ready for review May 4, 2026 19:29
@MickLesk MickLesk requested a review from a team as a code owner May 4, 2026 19:29
@CrazyWolf13 CrazyWolf13 merged commit 559cfff into main May 4, 2026
1 check passed
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugfix update script A change that updates a script

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Databasus does not work after install

4 participants