1#!/bin/sh
2
3set -u
4set -e
5
6# Add a console on tty1
7if [ -e ${TARGET_DIR}/etc/inittab ]; then
8    grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \
9	sed -i '/GENERIC_SERIAL/a\
10tty1::respawn:/sbin/getty -L  tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab
11# systemd doesn't use /etc/inittab, enable getty.tty1.service instead
12elif [ -d ${TARGET_DIR}/etc/systemd ]; then
13    mkdir -p "${TARGET_DIR}/etc/systemd/system/getty.target.wants"
14    ln -sf /lib/systemd/system/getty@.service \
15       "${TARGET_DIR}/etc/systemd/system/getty.target.wants/getty@tty1.service"
16fi
17