-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoolerdash.install
More file actions
143 lines (121 loc) · 5.79 KB
/
coolerdash.install
File metadata and controls
143 lines (121 loc) · 5.79 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Created by: damachin3 (damachine3 at proton dot me)
# Website: https://github.com/damachine/coolerdash
# Pacman install hooks
pre_install() {
# Stop legacy service
if systemctl list-unit-files coolerdash.service | grep -q coolerdash; then
systemctl stop coolerdash.service
systemctl disable coolerdash.service
fi
# Remove legacy files
rm -f /etc/systemd/system/coolerdash.service
rm -f /etc/systemd/system/coolerdash-helperd.service
rm -f /etc/systemd/system/multi-user.target.wants/coolerdash-helperd.service
rm -rf /etc/systemd/system/cc-plugin-coolerdash.service.d
rm -f /usr/lib/systemd/system/coolerdash-helperd.service
rm -f /usr/lib/udev/rules.d/99-coolerdash.rules
rm -rf /opt/coolerdash
rm -rf /etc/coolerdash
rm -f /etc/coolercontrol/plugins/coolerdash/config.ini
rm -f /etc/coolercontrol/plugins/coolerdash/ui.html
rm -f /etc/coolercontrol/plugins/coolerdash/LICENSE
rm -f /etc/coolercontrol/plugins/coolerdash/coolerdash
rm -f /usr/share/applications/coolerdash-settings.desktop
rm -f /bin/coolerdash
rm -f /usr/bin/coolerdash
# Remove legacy user
if id -u coolerdash &>/dev/null; then
userdel -rf coolerdash
fi
}
post_install() {
# Remove legacy files
rm -f /etc/systemd/system/multi-user.target.wants/coolerdash-helperd.service
rm -f /etc/systemd/system/coolerdash-helperd.service
rm -f /usr/lib/systemd/system/coolerdash-helperd.service
rm -rf /etc/systemd/system/cc-plugin-coolerdash.service.d
rm -f /usr/lib/udev/rules.d/99-coolerdash.rules
# Ensure correct permissions on config.json
chmod 600 /etc/coolercontrol/plugins/coolerdash/config.json 2>/dev/null || true
chmod 600 /etc/coolercontrol/plugins/coolerdash/credentials.json 2>/dev/null || true
systemctl daemon-reload
# Restart plugin service directly if it already exists (reinstall case)
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."
else
# Fresh install: restart CoolerControl so it discovers and starts the plugin service
if systemctl list-unit-files coolercontrold.service | grep -q coolercontrold; then
systemctl restart coolercontrold.service || echo "Note: CoolerControl restart failed."
fi
fi
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() {
# Remove legacy files
rm -f /etc/systemd/system/multi-user.target.wants/coolerdash-helperd.service
rm -f /etc/systemd/system/coolerdash-helperd.service
rm -f /usr/lib/systemd/system/coolerdash-helperd.service
rm -rf /etc/systemd/system/cc-plugin-coolerdash.service.d
rm -f /usr/lib/udev/rules.d/99-coolerdash.rules
# Ensure correct permissions on config.json
chmod 600 /etc/coolercontrol/plugins/coolerdash/config.json 2>/dev/null || true
chmod 600 /etc/coolercontrol/plugins/coolerdash/credentials.json 2>/dev/null || true
systemctl daemon-reload
# Restart plugin
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
echo "================================================================"
echo "CoolerDash upgraded successfully."
echo "Note: config.json is preserved. If a new template was shipped,"
echo " compare it with /etc/coolercontrol/plugins/coolerdash/config.json.pacnew"
echo "Note: credentials.json is never overwritten by updates."
echo "================================================================"
}
pre_remove() {
# Stop legacy service
if systemctl list-unit-files coolerdash.service | grep -q coolerdash; then
systemctl stop coolerdash.service
systemctl disable coolerdash.service
fi
# Stop plugin
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
# Stop helperd
if systemctl list-unit-files coolerdash-helperd.service | grep -q coolerdash-helperd; then
systemctl stop --no-block coolerdash-helperd.service
systemctl disable coolerdash-helperd.service
fi
# Remove legacy files
rm -f /etc/systemd/system/coolerdash-helperd.service
rm -f /etc/systemd/system/coolerdash.service
rm -f /etc/systemd/system/multi-user.target.wants/coolerdash-helperd.service
rm -rf /etc/systemd/system/cc-plugin-coolerdash.service.d
rm -f /etc/coolercontrol/plugins/coolerdash/config.ini
rm -f /etc/coolercontrol/plugins/coolerdash/ui.html
rm -f /etc/coolercontrol/plugins/coolerdash/LICENSE
rm -f /etc/coolercontrol/plugins/coolerdash/coolerdash
rm -f /usr/share/applications/coolerdash-settings.desktop
rm -f /bin/coolerdash
rm -f /usr/bin/coolerdash
rm -rf /opt/coolerdash
rm -rf /etc/coolerdash
# Remove legacy user
if id -u coolerdash &>/dev/null; then
userdel -rf coolerdash
fi
systemctl daemon-reload
# Restart CoolerControl
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 "================================================================"
}