# Autologin a user & autostarting a application.



## Green_Bandit (May 14, 2010)

I've searched all over google for a easy way to let Freebsd Autologin a non-root user, and execute a script to start a application after login.
All the guides that I could find, were from 2004 to 2006, and all my tests in virtualbox gave me something like this:






(Used the username _server_ in this test example)

I even checked for spelling mistakes, and accidental uppercase or lowercase letter, but i still get the same results.

So can anyone explain to me how i can make Freebsd do as i want, instead of being dependent on manual login and starting a application?


----------



## swa (May 14, 2010)

Why not make use of the users crontab, something like 

```
@reboot /path/to/app
```
http://www.freebsd.org/doc/en/books/handbook/configtuning-starting-services.html


----------



## Green_Bandit (May 15, 2010)

swa said:
			
		

> Why not make use of the users crontab, something like
> 
> ```
> @reboot /path/to/app
> ...



Can you give me a example?
I'm not really used to tinkering in *NIX based systems at this level.
Been pampered with Windows and Ubuntu makes it difficult to grasp the concept of this.


----------



## DutchDaemon (May 15, 2010)

The crontab option will only start an application for a user at boot time. It does nothing else, so no auto-login is supplied. I guess you want a user to boot straight into an aplication without any login. What you want is possible, and I've seen it done (booting straight into a menu with choices), but I can't remember what has to be done


----------



## ProFTP (May 15, 2010)

Green_Bandit said:
			
		

> dependent on manual login and starting a application?



IPC? 
need to open pseudo terminal?

IPC::Run - system() and background procs w/ piping, redirs, ptys (Unix, Win32)


> # Refusing to accept input unless stdin is a tty.
> 
> Some programs, for security reasons, will only accept certain types of input from a tty. su, notable, will not prompt for a password unless it's connected to a tty.
> 
> If this is your situation, use a pseudo terminal ('<pty<' and '>pty>').


----------



## jalla (May 15, 2010)

I think it might be useful if you posted some details on what your script looks like and what you did to run it.
I remember having done this, but it's 10+ years ago (in the days of 3.x).
As I recall it was done by replacing getty on the tty with a custom script/cmd or something?

If you have pointers to those guides you mention, that may trigger my memory.


----------



## Green_Bandit (May 15, 2010)

jalla said:
			
		

> I think it might be useful if you posted some details on what your script looks like and what you did to run it.
> I remember having done this, but it's 10+ years ago (in the days of 3.x).
> As I recall it was done by replacing getty on the tty with a custom script/cmd or something?
> 
> If you have pointers to those guides you mention, that may trigger my memory.



Here's two of those i still could find in my web history, that i've tried.
Gonna try once more in Virtualbox
http://webcache.googleusercontent.c...0J:keyhell.org/advices.html+freebsd+autologin
http://webcache.googleusercontent.c...d.org/showthread.php?t=6782+freebsd+autologin


----------



## Green_Bandit (May 16, 2010)

Well I've made progress (kinda).
Managed to make the system autologin and start the vm of my choice using this guide

http://blogs.koolwal.net/2009/03/15/howto-autologin-into-your-linux-system-without-xdm-gdm-kdm-etc/
I just made a /etc/rc.local file that looks like this

su - server -c startxfce4

Now i just need to figure out of to autostart other applications after user login


----------



## Beastie (May 16, 2010)

1. Xfce has a native method for autoloading applications;
2. You could modify the last lines of the /usr/local/lib/X11/xinit/xinitrc script which I _believe_ is used by default when a user lacks ~/.x* files;
3. You could use your "default" user's ~/.xinitrc or ~/.xsession files.


----------



## Green_Bandit (May 16, 2010)

Ended up using xfce4-session-settings, since i also had installed XFCE, and had already configured it to autologin & autostart xfce.
Does exactly what i want, and easy to use.


----------



## SirDice (May 17, 2010)

GDM can easily be configured to autologin.


----------

