pcp-image/container-entrypoint

42 lines
1.7 KiB
Bash

#!/bin/bash -eu
# SPDX-License-Identifier: (LGPL-2.1+ AND GPL-2.0+)
ALL_PCP_SERVICES='pmcd,pmie,pmlogger,pmproxy'
export PCP_SERVICES=${PCP_SERVICES:-${ALL_PCP_SERVICES}}
export HOST_MOUNT=${HOST_MOUNT:-''}
export REDIS_SERVERS=${REDIS_SERVERS:-'localhost:6379'}
mkdir -p /etc/systemd/system/pmcd.service.d
# shellcheck disable=SC2016
envsubst '$HOST_MOUNT' < /usr/share/container-scripts/pcp/10-host_mount.conf.template > /etc/systemd/system/pmcd.service.d/10-host_mount.conf
# shellcheck disable=SC2016
envsubst '$REDIS_SERVERS' < /usr/share/container-scripts/pcp/pmproxy.conf.template > /etc/pcp/pmproxy/pmproxy.conf
echo "Enabling PCP services: ${PCP_SERVICES}"
for service in ${ALL_PCP_SERVICES//,/ }; do
if [[ ",${PCP_SERVICES}," = *",${service},"* ]]; then
systemctl enable "${service}" 2> /dev/null
else
# pcp-zeroconf enables some PCP services already -> disable them if not requested
systemctl disable "${service}" 2> /dev/null
# prevent other services from starting (due to systemd dependencies) by masking them
systemctl mask "${service}" 2> /dev/null
fi
done
# After systemd starts, something is creating syslinks in
# /var/lib/pcp/config/pmieconf/dm and /var/lib/pcp/config/pmieconf/zeroconf
# to the following non-existing locations. Pmie fails to start because of these broken links.
# Pmie starts okay if the targets are empty files, so this is a workaround for now.
mkdir -p /etc/pcp/pmieconf/dm
touch /etc/pcp/pmieconf/dm/data_high_util
touch /etc/pcp/pmieconf/dm/metadata_high_util
mkdir -p /etc/pcp/pmieconf/zeroconf
touch /etc/pcp/pmieconf/zeroconf/all_threads
chown pcp:pcp /var/log/pcp/pmlogger
echo Starting systemd...
exec "$@"