Files
NLnetLabs-krill/debian/postinst
T
ximon18andGitHub e40131aaea Deb pkg fixes (#288)
Various Debian packaging fixes and improvements: (note: depends on a fork of cargo deb as some cargo deb PRs are still pending)
  - Fix: Krill will now be restarted when the package is upgraded (also when upgrading from v0.7.0/v0.7.1/v0.7.2/v0.7.3 packages) (fixes #280).
  - Fix: systemd warning after apt remove (fixes #275).
  - Fix: Lintian error "manpage-not-compressed" (via cargo deb PR 133).
  - Fix: Lintian error "debian-changelog-file-missing" (via cargo deb PR 137). Note: the changelog is only a minimal pointer to the GitHub release notes, attributed to the user doing the pull requestor or merge to master.
  - Fix: Lintian error "copyright-without-copyright-notice".
  - Fix: Cargo Deb "warning: extended-description field missing" (via cargo deb PR 138).
  - Fix: Incorrect systemd unit "vendor preset: enabled" (via PR 276).
  - Fix: Remove unused /etc/krill directory created by the "ConfigurationDirectory" systemd unit key.
Also:
  - Use debhelper dh_installsystemd style support for systemd unit installation (based on official Debian debhelper dh_installsystemd autoscripts & logic) instead of incomplete/erroneous hand crafted maintainer scripts (via cargo deb PR 135).
  - Uses systemd unit masking on package removal as recommended (see PR 276).
  - Enables bash echo output for pkg workflow run steps.
  - Verfies built deb packages with Lintian.
  - Less repetition in Cargo.toml.
2020-07-30 09:25:03 +02:00

48 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
set -e
KRILL_CONF="/etc/krill.conf"
KRILL_HOME="/var/lib/krill/"
KRILL_DATA="${KRILL_HOME}data/"
KRILL_USER="krill"
create_user() {
if id ${KRILL_USER} > /dev/null 2>&1; then return; fi
adduser --system --home "${KRILL_HOME}" --group ${KRILL_USER}
}
generate_password() {
# Tries not to depend on too many other commmands
# being installed.
date | md5sum | awk '{print $1}'
}
create_first_time_configuration() {
if [ ! -f "${KRILL_CONF}" ]; then
# generate a token for authenticating with Krill
GENERATED_TOKEN="$(generate_password)"
# generate a config file using our preferred filesystem locations
# and generated token
# note: we don't configure Krill to store its PID file under /var/run/
# because that requires root privileges potentially at least once per
# boot, and Krill doesn't drop privileges yet so when run as a non-root
# user has no right to create the file or missing /var/run/subdir.
# See: https://stackoverflow.com/a/28312577
krillc config simple \
--data "${KRILL_DATA}" \
--token "${GENERATED_TOKEN}" |
sed -e "s|^\(### log_type.\+\)|\1\nlog_type = \"syslog\"|" \
> "${KRILL_CONF}"
fi
}
case "$1" in
configure)
create_user
create_first_time_configuration
;;
esac
#DEBHELPER#