Skip to content

Commit b01711c

Browse files
rcourtmanclaude
andcommitted
fix: preserve .env file during automatic updates
- Backup .env file before git clean to prevent configuration loss - Restore .env file after git operations with proper ownership - Ensures user configuration survives cron-based updates 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 68ce7ca commit b01711c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

scripts/install-pulse.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,10 +1047,36 @@ perform_update() {
10471047
return 1
10481048
fi
10491049

1050+
# Backup .env file before cleaning to preserve user configuration
1051+
local env_backup_path=""
1052+
if [ -f "$PULSE_DIR/.env" ]; then
1053+
env_backup_path="/tmp/.env.backup.$$"
1054+
print_info "Backing up .env file to preserve user configuration..."
1055+
if cp "$PULSE_DIR/.env" "$env_backup_path"; then
1056+
print_success ".env file backed up temporarily."
1057+
else
1058+
print_warning "Failed to backup .env file. Configuration may be lost."
1059+
env_backup_path=""
1060+
fi
1061+
fi
1062+
10501063
print_info "Cleaning untracked files and directories..."
10511064
if ! sudo -u "$PULSE_USER" git clean -fd; then
10521065
print_warning "Failed to clean untracked files, continuing anyway."
10531066
fi
1067+
1068+
# Restore .env file after cleaning
1069+
if [ -n "$env_backup_path" ] && [ -f "$env_backup_path" ]; then
1070+
print_info "Restoring .env file..."
1071+
if cp "$env_backup_path" "$PULSE_DIR/.env"; then
1072+
chown "$PULSE_USER":"$PULSE_USER" "$PULSE_DIR/.env"
1073+
chmod 600 "$PULSE_DIR/.env"
1074+
print_success ".env file restored successfully."
1075+
else
1076+
print_warning "Failed to restore .env file from backup."
1077+
fi
1078+
rm -f "$env_backup_path"
1079+
fi
10541080

10551081
print_info "Fetching latest changes from git [running as user $PULSE_USER]..."
10561082
if [ -n "$TARGET_TAG" ]; then

0 commit comments

Comments
 (0)