Files
NLnetLabs-krill/debian/scripts/postinst
T
Ximon Eighteen 8431642a4a Create Krill DEB and RPM packages via GH actions:
- Assumes that the target system has ca-certificates installed already.
  - Vendor OpenSSL to support Ubuntu 16.04 which only has OpenSSL 1.0.0.
  - Use GH caching to avoid repeat compilation of unchanging cargo deb and krill dependencies.
  - Build in Docker containers as GH runners have too many non-standard packages and libraries pre-installed.
  - Sanity check the created DEB in targeted O/S versions via LXC/LXD containers (for systemd support).
2020-06-23 12:55:17 +02:00

45 lines
1.3 KiB
Bash
Executable File

#!/bin/sh -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