Re: Running a service on a console in the foreground

2022-11-20 Thread Valery Ushakov
On Sun, Nov 20, 2022 at 15:41:24 +, Benny Siegert wrote:

> Is it possible to have some program running in the foreground on one of the
> VTs on startup, instead of getty? I would like it to start up on boot and
> use the console for input and output. How do you set up such a thing, or is
> this simply not supported?

Use getty autologin ("al") feature in gettytab(5)?

-uwe


Re: Running a service on a console in the foreground

2022-11-20 Thread adr

On Sun, 20 Nov 2022, Benny Siegert wrote:

Hi!

Is it possible to have some program running in the foreground on one of the 
VTs on startup, instead of getty? I would like it to start up on boot and use 
the console for input and output. How do you set up such a thing, or is this 
simply not supported?


If I grasped right what you want to do, I would let getty initialize the tty, 
define a custom type in /etc/gettytab like:

[...]
# just add al to Pc
autologin:\
:al=your_user_name:np:ig:ht:
[...]

an configure your desired tty in /etc/ttys:

[...]
ttyE1   "/usr/libexec/getty autologin"  wsvt25  on secure
[...]

Then add something like this in your_user_name's .profile
[...]
if tty | grep -q /dev/ttyE1; then
exec $YOURPROGAM
fi
[...]

But be aware, now ttyE1+$YOURPROGRAM is an open door to your_user_name's
account.


Re: Running a service on a console in the foreground

2022-11-20 Thread Brad Spencer
Benny Siegert  writes:

> Hi!
>
> Is it possible to have some program running in the foreground on one of 
> the VTs on startup, instead of getty? I would like it to start up on boot 
> and use the console for input and output. How do you set up such a thing, 
> or is this simply not supported?


There are a few considerations, but ya, it should be possible.

One method would be to disable getty on the tty you want to use, or
allocate another one and then put into something like /etc/rc.local
"program < /dev/ttyEx > /dev/ttyEx 2>&1 &" and see how that works for
you.  This can be tested without messing with /etc/rc.local by disable
getty and then just trying to start the program in another shell (on
another virtual console or otherwise).  The problems here may be the
ownership of the /dev/ttyEx device (x being whatever virtual console
number you used) and the general lack of tty set up.  You may be able to
solve some of this with ownership changes on the /dev/ttyEx device and
hopefully your program sets the tty up completely on its own.

If you can tolerate some interaction you can make getty use something
other than login as the login program.  On my DOM0 systems I have this
in my /etc/ttys:

ttyE3   "/usr/libexec/getty Pcsh"   wsvt25  on  secure

and then this in /etc/gettytab:

Pcsh|Pcsh console:\
:np:ig:ht:lo=/etc/run_shx:

and then this in /etc/run_shx as a executable shell script:

#!/bin/sh

if [ -f "/rescue/csh" ]
then
exec /rescue/csh -l
else
echo "Missing /rescue/csh"
exit 1
fi


In this case /dev/ttyE3 will present a username prompt, but anything
entered will work and it will drop you into a csh shell.  The reason to
do all of this, as opposed to just starting /rescue/csh directly, is
that getty sets up the /dev/tty device a bit, so things like job control
and the like work as expected.  You may not need this set up if you are
not trying to run a shell (I ended up using csh mostly because it just
worked, sh and ksh still didn't like the arrangement).  The effect is to
give me the ability to log into the console of the DOM0 without a
password, and have a workable set up to fix something if the normal
username / password stuff won't let me in as expected (i.e. maybe
kerberos is unavailable or ldap, or something.. or whatever...).






-- 
Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org


Re: Running a service on a console in the foreground

2022-11-20 Thread Martin Husemann
On Sun, Nov 20, 2022 at 11:10:14AM -0500, Greg Troxel wrote:
> 
> Benny Siegert  writes:
> 
> > Is it possible to have some program running in the foreground on one
> > of the VTs on startup, instead of getty? I would like it to start up
> > on boot and use the console for input and output. How do you set up
> > such a thing, or is this simply not supported?
> 
> 1) You could try putting it in /etc/ttys.  Your program would have to be
> getty-ish.

Some install CDs do that to run sysinst, see e.g.
src/distrib/amd64/cdroms/etc.rc and src/distrib/amd64/installimage/etc.ttys.
Sysinst is not "getty-ish" in any way AFAICT.

Martin


Re: Running a service on a console in the foreground

2022-11-20 Thread Greg Troxel

Benny Siegert  writes:

> Is it possible to have some program running in the foreground on one
> of the VTs on startup, instead of getty? I would like it to start up
> on boot and use the console for input and output. How do you set up
> such a thing, or is this simply not supported?

1) You could try putting it in /etc/ttys.  Your program would have to be
getty-ish.

2) You could tell /etc/ttys not to do anything, and then have your
program revoke all tty, and then open the one you want.  Surely this is
doable.


I would say 1 likely has a gotcha I haven't thought  of, but maybe not,
and even if so working through it, reading the getty code for
inspiration, is what I would do if I had your requirements/wishes.


signature.asc
Description: PGP signature


Running a service on a console in the foreground

2022-11-20 Thread Benny Siegert

Hi!

Is it possible to have some program running in the foreground on one of 
the VTs on startup, instead of getty? I would like it to start up on boot 
and use the console for input and output. How do you set up such a thing, 
or is this simply not supported?


--
Benny