blob: 709e1ac26f6f86fe0f9f03ed59ee65e501e5c88c (
plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
|
_ensure_credentials() {
if [ ! -f /var/lib/coolercontrol/plugins/coolerdash/credentials.json ]; then
mkdir -p /var/lib/coolercontrol/plugins/coolerdash
printf '{\n "access_token": ""\n}\n' > /var/lib/coolercontrol/plugins/coolerdash/credentials.json
fi
}
_set_permissions() {
chmod 600 /var/lib/coolercontrol/plugins/coolerdash/config.json 2>/dev/null || true
chmod 600 /var/lib/coolercontrol/plugins/coolerdash/credentials.json 2>/dev/null || true
}
_refresh_coolercontrol() {
command -v systemctl >/dev/null 2>&1 || return 0
systemctl daemon-reload
systemctl reset-failed cc-plugin-coolerdash.service >/dev/null 2>&1 || true
if systemctl list-unit-files cc-plugin-coolerdash.service | grep -q cc-plugin-coolerdash; then
systemctl restart cc-plugin-coolerdash.service || echo "Note: Plugin restart failed."
fi
if systemctl list-unit-files coolercontrold.service | grep -q coolercontrold; then
systemctl restart coolercontrold.service || echo "Note: CoolerControl restart failed."
fi
}
_link_default_lcd_image() {
mkdir -p /etc/coolercontrol
if [ -f /var/lib/coolercontrol/plugins/coolerdash/coolerdash.png ]; then
if [ -L /etc/coolercontrol/lcd_image.png ] || [ ! -e /etc/coolercontrol/lcd_image.png ]; then
ln -sfn /var/lib/coolercontrol/plugins/coolerdash/coolerdash.png /etc/coolercontrol/lcd_image.png
fi
fi
}
post_install() {
_ensure_credentials
_link_default_lcd_image
_set_permissions
_refresh_coolercontrol
echo "================================================================"
echo "CoolerDash installed successfully."
echo "Set your Access Token in the CoolerDash Settings UI."
echo "The token is auto-persisted to credentials.json on startup."
echo "================================================================"
}
post_upgrade() {
_ensure_credentials
_link_default_lcd_image
_set_permissions
_refresh_coolercontrol
echo "================================================================"
echo "CoolerDash upgraded successfully."
echo "Note: config.json is preserved. If a new template was shipped,"
echo " compare it with /var/lib/coolercontrol/plugins/coolerdash/config.json.pacnew"
echo "Note: credentials.json is never overwritten by updates."
echo "================================================================"
}
pre_remove() {
command -v systemctl >/dev/null 2>&1 || return 0
if systemctl list-unit-files cc-plugin-coolerdash.service | grep -q cc-plugin-coolerdash; then
systemctl stop cc-plugin-coolerdash.service
systemctl disable cc-plugin-coolerdash.service
fi
systemctl daemon-reload
if systemctl list-unit-files coolercontrold.service | grep -q coolercontrold; then
systemctl restart coolercontrold.service || echo "Note: CoolerControl restart failed."
fi
echo "================================================================"
echo "CoolerDash removed."
echo "================================================================"
}
|