#!/bin/sh # postinst script for signalfx-agent # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see https://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in configure) bundle_dir=/usr/lib/signalfx-agent getent passwd signalfx-agent >/dev/null || \ useradd --system --home-dir $bundle_dir --no-create-home --shell /sbin/nologin signalfx-agent setcap CAP_SYS_PTRACE,CAP_DAC_READ_SEARCH=+eip $bundle_dir/bin/signalfx-agent # Get the binaries' interpreter patched properly ${bundle_dir}/bin/patch-interpreter ${bundle_dir} echo "The SignalFx agent has been successfully installed." echo "If you do not already have a access token configured, please add it to /etc/signalfx/agent.yaml and then start the agent." ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # All of the autogenerated sections are copied and hardcoded here so that we # can conditionalize the use of deb-systemd-helper. if command -v deb-systemd-helper; then deb-systemd-helper unmask signalfx-agent.service >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled signalfx-agent.service; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable signalfx-agent.service >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state signalfx-agent.service >/dev/null || true fi fi if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then # In case this system is running systemd, we need to ensure that all # necessary tmpfiles (if any) are created before starting. if [ -d /run/systemd/system ] ; then systemd-tmpfiles --create /usr/lib/tmpfiles.d/signalfx-agent.conf >/dev/null || true if command -v update-rc.d && [ -e "/etc/init.d/signalfx-agent" ]; then rm -f /etc/init.d/signalfx-agent update-rc.d -f signalfx-agent remove >/dev/null || exit $? fi fi fi if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then if [ -x "/etc/init.d/signalfx-agent" ]; then if command -v update-rc.d; then update-rc.d signalfx-agent defaults >/dev/null || exit $? fi fi fi exit 0