-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck-and-rebuild.sh
More file actions
68 lines (57 loc) · 1.85 KB
/
Copy pathcheck-and-rebuild.sh
File metadata and controls
68 lines (57 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -euo pipefail
PLASMOID_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/plasma/plasmoids/org.kde.plasma.proxmox"
LOG_FILE="$PLASMOID_DIR/rebuild.log"
FINGERPRINT_FILE="$PLASMOID_DIR/.build_fingerprint"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
INSTALL_SCRIPT="$SCRIPT_DIR/install.sh"
log() {
printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$*" >> "$LOG_FILE"
}
notify_error() {
if command -v notify-send >/dev/null 2>&1; then
notify-send --urgency=critical \
--icon=dialog-error \
"Proxmox Plasmoid" \
"Auto-rebuild failed. Check $LOG_FILE for details."
fi
}
# Hash of all watched runtime library paths - distro-agnostic via ldconfig.
get_fingerprint() {
ldconfig -p 2>/dev/null \
| grep -iE 'libplasma|libQt6|libvncclient|libqtermwidget' \
| awk '{print $NF}' \
| sort \
| xargs -r md5sum 2>/dev/null \
| md5sum \
| cut -d' ' -f1
}
if [ ! -d "$PLASMOID_DIR" ]; then
log "ERROR: Plasmoid directory not found: $PLASMOID_DIR"
notify_error
exit 1
fi
if [ ! -f "$INSTALL_SCRIPT" ]; then
log "ERROR: Install script not found: $INSTALL_SCRIPT"
notify_error
exit 1
fi
CURRENT_FINGERPRINT="$(get_fingerprint)"
STORED_FINGERPRINT=""
[ -f "$FINGERPRINT_FILE" ] && STORED_FINGERPRINT="$(cat "$FINGERPRINT_FILE")"
if [ "$CURRENT_FINGERPRINT" = "$STORED_FINGERPRINT" ]; then
log "INFO: Fingerprint unchanged — no rebuild needed."
exit 0
fi
log "INFO: Library change detected."
log "INFO: stored: ${STORED_FINGERPRINT:-<none>}"
log "INFO: current: $CURRENT_FINGERPRINT"
log "INFO: Starting rebuild..."
if (cd "$SCRIPT_DIR" && bash "$INSTALL_SCRIPT" --rebuild >> "$LOG_FILE" 2>&1); then
printf '%s' "$CURRENT_FINGERPRINT" > "$FINGERPRINT_FILE"
log "INFO: Rebuild and reinstall succeeded."
else
log "ERROR: Rebuild failed. Plasmoid may be broken until next successful rebuild."
notify_error
exit 1
fi