cluster-deployment/jobs/collectd/collectd.job

25 lines
714 B
Bash
Executable file

#!/usr/bin/env bash
if [[ -z "${COLLECTD_PW}" ]]; then
echo "Error: COLLECTD_PW environment variable is not set";
exit 1;
fi
RUN "sudo apt-get install -y collectd liboping0";
tmpfile_collectd="$(mktemp --tmpdir "collectd-XXXXXXX")";
chmod 0600 "${tmpfile_collectd}";
sed -e "s/{{{PASSWORD}}}/${COLLECTD_PW}/g" <"${JOBFILE_DIR}/collectd.conf" >"${tmpfile_collectd}";
unset COLLECTD_PW;
COPY "${tmpfile_collectd}" "/tmp/collectd.conf";
rm "${tmpfile_collectd}";
RUN "sudo chown root:root /tmp/collectd.conf";
RUN "sudo chmod 0600 /tmp/collectd.conf";
RUN "sudo mv /tmp/collectd.conf /etc/collectd/collectd.conf";
RUN "sudo systemctl restart collectd.service";
RUN "sudo systemctl enable collectd.service";