Busybox getty
Overview
Alpine Linux uses by default agetty for managing terminal lines which is an extra package. We can use busybox' getty instead and save space.
Service configuration
The service for running busybox getty will be called bgetty
.
Create a default configuration file
sudo true
sudo tee /etc/conf.d/bgetty <<EOF
# Set the baud rate of the terminal line
# 0 .. leave alone
baud="0"
# set the terminal type
#term_type="linux"
# extra options to pass to getty for this port
bgetty_options=""
EOF
Create a service script
sudo true
sudo tee /etc/init.d/bgetty <<EOF
#!/sbin/openrc-run
# Copyright (c) 2017 The OpenRC Authors.
# See the Authors file at the top-level directory of this distribution and
# https://github.com/OpenRC/openrc/blob/master/AUTHORS
#
# This file is part of OpenRC. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this
# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
# This file may not be copied, modified, propagated, or distributed
# except according to the terms contained in the LICENSE file.
#
# Adapted for busybox getty gl@x-net.at
description="start busybox getty on a terminal line"
supervisor=supervise-daemon
port="${RC_SVCNAME#*.}"
respawn_period="${respawn_period:-60}"
term_type="${term_type:-linux}"
baud="${baud:-0}"
command=/sbin/getty
command_args_foreground="${bgetty_options} ${baud} ${port} ${term_type}"
pidfile="/run/${RC_SVCNAME}.pid"
depend() {
after local
keyword -prefix
provide getty
}
start_pre() {
if [ -z "$port" ]; then
eerror "${RC_SVCNAME} cannot be started directly. You must create"
eerror "symbolic links to it for the ports you want to start"
eerror "getty on and add those to the appropriate runlevels."
return 1
else
export EINFO_QUIET="${quiet:-yes}"
fi
}
stop_pre()
{
export EINFO_QUIET="${quiet:-yes}"
}
EOF
sudo chmod +x /etc/init.d/bgetty