2

So I've written a simple UI in C. Its read only and displays system information like disk space, network info, etc.

I am running ubuntu server 14.04 and currently when the appliance starts up I am prompted with the classic ubuntu text login and password prompt. Instead, I would like my program executable (compiled with gcc) to run and be displayed before this login prompt. What would be the best way to do so?

Please pardon my lack of "terminology". I'm relatively new in this area and don't have much experience with shell scripting. Let me know if there is any more info needed to answer the question..I was having a bit of trouble myself wording it.. :) Thanks in advance!

Edit: Picture to get the idea. It's something similar though this is just something I found while googling to demonstrate the idea.

Edit 2: Preferably the TUI would be displayed before the user logs in; however, in reality it doesn't matter if its before a user is prompted for the login and password or immediately after. enter image description here

4
  • Does your program output text or images? Your title says images, but the body of the question seems to imply text. Jul 18, 2016 at 23:49
  • It's written with ncurses, so its essentially text used to emulate images built in the terminal. I'll attach a picture above here: The images I mean are essentially a colored background (instead of white above some text may be highlighted in green, and there are colored panels in the background, etc).
    – Funsaized
    Jul 19, 2016 at 12:46
  • So the images are, in fact, text? That matters because the tools to display images and text are completely different. While it's possible to display images on some consoles, it doesn't work everywhere, it depends how the machine is set up. Text on the other hand works everywhere, and colored text virtually everywhere. Jul 19, 2016 at 18:20
  • Yes I believe the images are all text based. Essentially all the program does is display text then exit when F1 is pressed. After F1 is pressed, I would like the user to be prompted with the normal login and everything to function normally :)
    – Funsaized
    Jul 19, 2016 at 18:21

1 Answer 1

1

The program that waits for a user to log in on a text console is known generically as getty. (By the way, the corresponding program type for GUI logins is a display manager) This is also the program that prompts for the user name. The program that prompts for the password is login. There are several implementations of getty; the default one in Ubuntu 14.04 is agetty.

In your case, I think the simplest solution would be to tell agetty to 1. not prompt for a username and 2. call a script which runs your program then calls login and tells login to display a username prompt.

The script:

#!/bin/sh
yourprogram
exec /bin/login

How to configure getty: edit /etc/init/tty1.conf and the similar files for other consoles. Change the exec line to

exec /sbin/getty -l /path/to/script --skip-login -8 38400 tty1

Another possibility is to leverage the fact that getty displays the file /etc/issue before the login prompt. If you only want to display text that doesn't change often, then you can write that text to /etc/issue. While you could arrange for the file to have dynamic content, it's a bit harder than changing the getty invocation. But then it would work for other login services such as SSH.

3
  • Cool I think that's what I need. Would I change the exec line on all of the tty#?
    – Funsaized
    Jul 19, 2016 at 20:40
  • @Broncos423 Yes, the login prompt works independently on each tty. Jul 19, 2016 at 21:07
  • @Broncos423 SSH does show the issue file, but it doesn't have the ability to run another program directly. Jul 20, 2016 at 23:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .