mirror of
https://github.com/myronblair/novacpx
synced 2026-06-30 17:50:41 -05:00
fix: all 6 code review findings
1. admin.js: dashboard setTimeout was after return (dead code) — restructured to assign template to const html, run setTimeout, then return html 2. DockerManager.php createStack: replaced SELECT LAST_INSERT_ID() with db->insert() which already returns lastInsertId correctly for SQLite 3. DockerManager.php setQuota: replaced ON DUPLICATE KEY UPDATE / VALUES() MySQL syntax with SQLite-compatible ON CONFLICT(user_id) DO UPDATE SET excluded.col syntax 4. post-restore.sh: PHP helper file now written ONCE at start of step 4 before any call to it (was written AFTER first call, causing silent failure) 5. post-restore.sh: git pull exit code now captured before pipeline (the while-read loop always exited 0, masking pull failures) 6. uninstall.sh: tar backup now aborts on failure (previously 2>/dev/null swallowed errors and rm -rf destroyed source unconditionally); also rm -f → rm -rf for .service.d drop-in directory
This commit is contained in:
+8
-3
@@ -70,8 +70,12 @@ log "Cron jobs"
|
||||
[[ -d /etc/postfix ]] && cp -a /etc/postfix "$BACKUP_DIR/configs/postfix" 2>/dev/null || true
|
||||
[[ -d /etc/dovecot ]] && cp -a /etc/dovecot "$BACKUP_DIR/configs/dovecot" 2>/dev/null || true
|
||||
|
||||
# Compress backup
|
||||
tar -czf "$BACKUP_ARCHIVE" -C "$(dirname $BACKUP_DIR)" "$(basename $BACKUP_DIR)" 2>/dev/null
|
||||
# Compress backup — abort if tar fails rather than silently delete unbackedup files
|
||||
tar -czf "$BACKUP_ARCHIVE" -C "$(dirname $BACKUP_DIR)" "$(basename $BACKUP_DIR)" || {
|
||||
echo -e "${RED}[✗]${NC} Backup archive creation FAILED. Uninstall aborted to protect your data."
|
||||
echo " Staging dir preserved at: $BACKUP_DIR"
|
||||
exit 1
|
||||
}
|
||||
rm -rf "$BACKUP_DIR"
|
||||
BACKUP_SIZE=$(du -sh "$BACKUP_ARCHIVE" | cut -f1)
|
||||
log "Backup archive: $BACKUP_ARCHIVE ($BACKUP_SIZE)"
|
||||
@@ -131,7 +135,8 @@ systemctl reload php8.3-fpm 2>/dev/null || true
|
||||
step "Removing systemd units"
|
||||
for svc in novacpx-web; do
|
||||
systemctl stop "$svc" 2>/dev/null; systemctl disable "$svc" 2>/dev/null
|
||||
rm -f "/etc/systemd/system/${svc}.service" "/etc/systemd/system/${svc}.service.d"
|
||||
rm -f "/etc/systemd/system/${svc}.service"
|
||||
rm -rf "/etc/systemd/system/${svc}.service.d"
|
||||
log "Removed: $svc"
|
||||
done
|
||||
systemctl daemon-reload
|
||||
|
||||
Reference in New Issue
Block a user