# Automatic login and start program

## whammoed

I would like to have my machine automatically login to a user I created and run a certain program when booted.  Is this possible?  This machine will not use a keyboard so logging in and starting up the program will not be possible.

----------

## db_404

Could you just start it from /etc/conf.d/local.start ?

e.g. add:

```

su user-i-want-command-to-run-as -c command-i-want-to-run

```

I do this for a number of things at startup.

----------

## boroshan

The easiest way is to kick it off from /etc/conf.d/local.start.

That still gives you the option of logging in over ssh if there's a problem as well.

----------

## oiper

well, if you mean to login to an X session... The best way I've found (using it for a mythtv box), is to use kdm|gdm to autologin a user to blackbox|fluxbox|etc and having programs run from the .fluxbox/startup file.

----------

## whammoed

thanks, i will try it tonight.

oiper, this is not for x session, just for program to run from console, but that is one of my favorite Ralphisms.  Other favorite:"It tastes like burning!"

thanks again

----------

## boroshan

the only thing to watch about local.start is that programs will run under root by default. 

```
su -c "command" user 
```

should solve that problem

----------

## whammoed

Well, this almost worked.  The program tries to start but it shuts down and complains about not being able to find a valid graphics console.  Program starts fine once I actually log in.  Is there a way to log in automatically first and then start the program?

----------

## boroshan

can I ask what the program is?

----------

## MrApples

 *whammoed wrote:*   

> thanks, i will try it tonight.
> 
> oiper, this is not for x session, just for program to run from console, but that is one of my favorite Ralphisms.  Other favorite:"It tastes like burning!"
> 
> thanks again

 

what is it for?

----------

## whammoed

The program is Advancemenu (advmenu)  It is a front end for arcade game emulation program.  This machine is supposed to have the feel of an arcade game, so it needs to boot up right into advmenu.  The program is designed to take control of the video card so it needs either framebuffer or svgalib.  I am using svgalib.

----------

## boroshan

I don't suppose there's a command line argument to tell it which virtual console to attach to or anything?

----------

## whammoed

no, just type advmenu and it starts right up.

----------

## boroshan

I have no idea, really, but it's an interesting problem...

I wonder, can you boot it by passing 

```
init=/path/to/advmenu
```

 as kernel options in GRUB/LILO? It all depends on how much infrastructure it needs I suppose, but if it just makes a grab for the graphics card...

----------

## db_404

 *boroshan wrote:*   

> 
> 
> I wonder, can you boot it by passing 
> 
> ```
> ...

 

But then nothing will get run on startup except advmenu, which probably won't work either as things like the soundcard etc. might need to be modprobed. 

I wonder if you could run it from /etc/inittab though e.g. replace 

```

c1:12345:respawn:/sbin/agetty 38400 tty1 linux

```

with

```

c1:12345:respawn:/path/to/advmenu

```

it might work.

----------

## boroshan

instead of agetty? yes, that sounds about right.

of course, you could always use an initrd to load sound card modules and all that, but I think your idea sounds better

----------

## whammoed

No go on that either.  Program went into a constant complain loop until I get:

respawning too fast : disabled for 5 minutes

used installation cd to get on and change it back

Ugh, helllllp!  :Confused: 

----------

## boroshan

so I suppose the next thing to do would be to have agetty launch advmenu instead of login. You can specify that with the -l option to agetty

And if you make agetty point to a script or a suid wrapper, you can make the program run as the desiered user.

----------

## db_404

 *whammoed wrote:*   

> No go on that either.  Program went into a constant complain loop until I get:
> 
> respawning too fast : disabled for 5 minutes
> 
> used installation cd to get on and change it back
> ...

 

I think an alt-F2 would have helped you in that situation - got you onto a login prompt on the second virtual terminal.

So that must mean agetty is doing somthing to 'set-up' the terminal in some way, boroshan's idea sounds like it would  be worth a try.  There has to be some info on how to do this out there,  all those folk with linux MAME cabinets must have hit the same problem.

An alternative aproach might be to get system to boot to X, have X auto login (I know there are ways to do that), then run some X front end to MAME.

Also I found  this https://forums.gentoo.org/viewtopic.php?t=193517 in the forums, which may (or may not) be helpful.

----------

## whammoed

boroshan, just went to try out your ideas when i realized I really don't know exactly what to do.  Instead of guessing could you give me some more specifics on how to modify the line with agetty and how to make and point to a script or wrapper?

Unfortunately there is little documentation on doing this with advmenu.  Most people are using it with dos unfortunately.  This was not an option for me with my super duper hardware and usb devices.  I would prefer to use advmenu and not use X.  Still, im sure someone has figured it out, but if they have a site on it I haven't found it, and they don't frequent the forum I do.  I feel like I'm breaking new ground here sometimes, but I may not be.

Here is a link to a thread concerning my machine...not bad for a noob to both linux and advmame/advmenu:

http://www.arcadecontrols.org/yabbse/index.php?board=10;action=display;threadid=21818

----------

## whammoed

Hmmmm, just googled again and found this:

http://ucsub.colorado.edu/~kelloggt/gentoomamecab.html

This didn't come up last time, maybe its new...anyway I knew I couldn't be a pioneer.  I will give it a go and post the results later.

thanks everyone

----------

## whammoed

It works, It works!

You guys obviously were on the right path.  Apparantly I did need to actually be logged in automatically for it to run...hence the C program.  I sure am glad there are smarter people than me out there.  Thank you guys for pointing me in the right direction.  I've learned a lot from these endeavors.

----------

## boroshan

 *whammoed wrote:*   

> boroshan, just went to try out your ideas when i realized I really don't know exactly what to do.  Instead of guessing could you give me some more specifics on how to modify the line with agetty and how to make and point to a script or wrapper?

 

Whoops! Must have posted that while  was asleep.

Glad it's working now!  :Very Happy: 

----------

