#!/bin/bash

# This file should contain the serial port to use for console login,
# eventually followed by the speed of the interface.
SERLOGINPORT=/var/run/seriallogin

# This is the time we wait before returning if there is no
# login prompt to start, in microsecs. The minimum is about 12 secs,
# so that init does not complain about a process respawning too fast.

NOLOGINTIME=1800000000 # 30 mins

if [ ! -s "$SERLOGINPORT" ]; then
	# We exec usleep, which is very low on resources.
	exec /bin/usleep "$NOLOGINTIME"
fi

PORT="$(< "$SERLOGINPORT" )"

# NOTE: cannot specify terminal type to getty since that would require having
# a baud rate.
exec /sbin/getty -L $PORT
