How to start tshark on ttyv1 and ttyv2 on boot

I'm trying to get tshark to load before login on my FreeBSD 13.1 server.
Preferably I would want ttyv0 to act as the server system notifications,
ttyv1 should run on boot: tshark -i re0 -t ud -P -V -u hms -b interval:86400 -w /tmp/tshark_re0_PV.pcap
and ttyv2 should run on boot: tshark -i re0 -P -t ud -u hms -b interval:86400 -w /tmp/tshark_re0.pcap
and ttyv3 should be the console presented to the user, the login.

I've searched everywhere for how to change ttyv pre-login and how to launch commands before login. I suspect the file /etc/rc.conf is used but I don't know how to run basic csh commands from /etc/rc.conf and I can't find a csh command to switch ttyv.

Anyone have any idea how I could accomplish this?
 
I did, but I'm still trying to figure out how to start a specific script when I log in, or preferably when the machine boots.
Anyone?
 
Set the tty lines you need to autologin by changing the argument for getty's line from Pc to al.Pc in /etc/ttys like the following:
Code:
ttyv7   "/usr/libexec/getty al.Pc"      xterm   onifexists secure

This will get you a root autologged on the specified tty. Then add something like the following to root's .shrc:
Code:
[ "$(tty)" = "/dev/ttyv7" ] && exec top -s1

exec makes (somewhat) sure that you can't really exit from the program running, or rather, when the program exits, getty will re-login.

Once all changes are in place, tell init to re-read /etc/ttys:
Code:
kill -HUP 1

P.S. make sure to replace ttyv7 with the ttys you need.
 
Back
Top