#!/bin/bash
#
# Copyright (c) Authors: https://www.armbian.com/authors
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.

# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd
# any changes will be lost on board support package update

THIS_SCRIPT="clear"
MOTD_DISABLE=""

# Clear runtime MOTD state
MOTD_RUN_DIR="/run/armbian-motd"
if [[ -d "$MOTD_RUN_DIR" ]]; then
  rm -f "${MOTD_RUN_DIR}/".*.printed 2>/dev/null
else
  mkdir -p "$MOTD_RUN_DIR" 2>/dev/null
fi

safe_source() { [[ -f "$1" ]] && . "$1"; }

# Optional overrides
safe_source /etc/default/armbian-motd
for f in ${MOTD_DISABLE}; do
	[[ "${f}" == "${THIS_SCRIPT}" ]] && exit 0
done

# Clear screen
if [ -f /bin/bash ]; then
export TERM="$(/bin/bash -c 'echo $TERM')"
fi
clear

exit 0
