fix: reset ownership at start of update mode before any file operations

- Moves chown to the very beginning of the update
- Ensures app user can write to /opt/receiptnext/ before build
- Removes redundant chown later in update (already done upfront)
This commit is contained in:
Claus Lohmar 2026-06-03 08:20:23 +00:00
parent afd4b6a1cf
commit b0dfb5fad3

View file

@ -73,6 +73,10 @@ if [ "${1:-}" = "-update" ]; then
cd "$INSTALL_DIR"
fi
# Reset ownership so the app user can write files.
APP_USER="${APP_USER:-${SUDO_USER:-$(whoami)}}"
sudo_if chown -R "${APP_USER}:${APP_USER}" "$INSTALL_DIR" 2>/dev/null || true
# Backup the database before making any changes.
if [ -f "$INSTALL_DIR/expenses.db" ]; then
BACKUP_DIR="$INSTALL_DIR/backups"