-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcoolerdash.install
More file actions
50 lines (43 loc) · 1.87 KB
/
Copy pathcoolerdash.install
File metadata and controls
50 lines (43 loc) · 1.87 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
_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
if systemctl is-active --quiet coolercontrold.service; then
systemctl restart coolercontrold.service || echo "Note: CoolerControl restart failed."
fi
}
post_install() {
_ensure_credentials
_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
_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 "================================================================"
}
post_remove() {
_refresh_coolercontrol
echo "================================================================"
echo "CoolerDash removed."
echo "================================================================"
}