#!/usr/bin/bash

# Get updated system information, including SSH keys and network devices,
# and generate an issue to display before login.

# Copyright (c) 2019 Fedora CoreOS Authors. All rights reserved.
# Copyright (c) 2013 The CoreOS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Modified from the CoreOS repository: https://github.com/coreos/init/blob/master/scripts/issuegen

set -e

. /usr/lib/console-login-helper-messages/libutil.sh
. /usr/lib/console-login-helper-messages/issuegen.defs

# Generate a final issue message from compiling the snippets.
# Pick 40 as a prefix as other files can order around it easily.
generated_file="/run/${PKG_NAME}/40_${PKG_NAME}.issue"
source_dirs=("${ETC_SNIPPETS}" "${RUN_SNIPPETS}" "${USR_LIB_SNIPPETS}")

cat_via_tempfile "${generated_file}" ".issue" "${source_dirs[@]}"

# Reload the agetty console upon generation of new issue snippet 
/usr/sbin/agetty --reload
