-
Notifications
You must be signed in to change notification settings - Fork 43
/
malarky.sh
executable file
·44 lines (34 loc) · 1.28 KB
/
malarky.sh
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
#!/bin/bash
if diff /usr/share/graphs1090/malarky.conf /etc/systemd/system/collectd.service.d/malarky.conf \
&& grep -qs -e 'DataDir "/run/collectd"' /etc/collectd/collectd.conf \
&& grep -qs -e 'DB=/run/collectd' /etc/default/graphs1090
then
echo ---------
echo write reducing measures already enabled, no need to do anything for this script!
echo ---------
exit 0
fi
systemctl stop collectd &>/dev/null
set -e
mkdir -p /etc/systemd/system/collectd.service.d
rm -f /etc/systemd/system/collectd.service
cp -f /usr/share/graphs1090/malarky.conf /etc/systemd/system/collectd.service.d/malarky.conf
set +e
sed -i -e 's?DataDir.*?DataDir "/run/collectd"?' /etc/collectd/collectd.conf
if ! grep -qs -e '^DB=' /etc/default/graphs1090; then
echo "DB=" >>/etc/default/graphs1090
fi
sed -i -e 's#^DB=.*#DB=/run/collectd#' /etc/default/graphs1090
systemctl daemon-reload
systemctl restart collectd
systemctl restart graphs1090
cat >/etc/cron.d/collectd_to_disk <<"EOF"
# restart collectd so data is saved to disk
42 23 * * * root /bin/systemctl restart collectd
EOF
# remove legacy stuff
rm -rf "$TARGET/graphs1090-writeback-backup1" "$TARGET/graphs1090-writeback-backup2"
rm -f /usr/share/graphs1090/noMalarky
echo ---------
echo write reducing measures enabled!
echo ---------