#!/bin/sh

#  To set correct TERM edit /etc/ngetty/Conf.  Examples:
#=environ=,TERM=linux
#=environ=,TERM=vt100,OTHER_ENV=123,PATH=/usr/bin:/bin,HOME=/

# It's possible to start ngetty also by init.  Comment the lines
# for getty in /etc/inittab and add a line for ngetty.  Example:
#
#	 # Run gettys in standard runlevels
#	 # 1:2345:respawn:/sbin/mingetty tty1
#        ...
#	 # 6:2345:respawn:/sbin/mingetty tty6
#
#	 # Run ngetty in standard runlevels
#	 ng:2345:respawn:/sbin/ngetty 1 2 3 4 5 6
#

cmdline="ngetty 8 9 10"
pid="/var/run/ngetty-8-9-10.pid"

exe="/sbin/ngetty"
starter="/sbin/ngetty-argv"


case $1 in
start)
	cd /
	if [ -f $pid ] ; then
	    echo May be one ngetty is running now
	    echo If not, remove the file $pid
	    exit 1
	fi
	if [ -x /sbin/ngetty-helper ] ; then
	    $starter " -D -S -e -p$pid -- $exe $cmdline" user null
	else
	    echo $0: Unable to find /sbin/ngetty-helper
	    exit 1;
        fi
	;;
stop)
	pkill -fx "$cmdline"
	rm -f $pid
	;;
status)
	[ -f $pid ] && read n < $pid
	[ $? -eq 0 ] && echo ngetty PID is: $n
	;;
*)
	echo "Usage: $0 start|stop|status"
	exit 1
esac
