View previous topic :: View next topic |
Author |
Message |
djpenguin Guru
Joined: 02 Sep 2004 Posts: 386
|
Posted: Wed Nov 24, 2004 2:48 am Post subject: Auto-login? |
|
|
I'm trying to set up an HTPC using gentoo. I've got the machine set up , now I'm trying to figure out a way to automatically log in a specified user every time the machine starts, then automatically start X.
I'm using IceWM as the window manager.
Can anybody point me in the right direction?
I'd also like to start freevo automatically after the WM starts, if there's any way to do that, I'd love to hear about it. |
|
Back to top |
|
|
denstark l33t
Joined: 02 Jun 2003 Posts: 654 Location: sd.ca.us
|
Posted: Wed Nov 24, 2004 2:56 am Post subject: |
|
|
GDM has auto login capabilities... emerge gdm, and then run gdmconfig, make sure your /etc/rc.conf file has DISPLAYMANAGER="gdm". In order to start gdm just do
Code: | /etc/init.d/xdm start |
to start gdm, and do
Code: | rc-update add xdm default | to get it to start at every boot.
Hope that answered your question. If you need more info just ask. _________________ Blog
Code: | denstark> starbuck authorizes torture?
rokstar> sure they do, you tried their coffee?
|
|
|
Back to top |
|
|
adsmith Veteran
Joined: 26 Sep 2004 Posts: 1386 Location: NC, USA
|
Posted: Wed Nov 24, 2004 3:05 am Post subject: |
|
|
xdm and gdm (and probably the others) have auto-login options.
e.g. run gdmsetup |
|
Back to top |
|
|
madmango Guru
Joined: 15 Jul 2003 Posts: 507 Location: PA, USA
|
Posted: Sat Nov 27, 2004 9:47 pm Post subject: |
|
|
There are WAY easier ways to do this then to have to emerge gdm. For example, on my arcade machine, I don't want to have the gnome libraries installed. So I don't want to use gdm or kdm, and xdm can't do autologin. So we need to login without a X login manager, and then start X once we're logged in.
First, the user we need to have logged in must not have a password. I haven't figured out how to to this with a password yet.
Code: |
passwd -d <username> |
Then we modify /etc/inittab and tell agetty to not ask for a username, and load a custom login program. Change Code: | c1:12345:respawn:/sbin/agetty 38400 tty1 linux | to Code: | c1:12345:respawn:/sbin/agetty -n -l /sbin/autologin 38400 tty1 linux |
Now we need to create the script we referenced above, /sbin/autologin. Here's the contents:
Code: | #!/bin/sh
exec login <username> |
Now your user should be logged in when you start your box. However, I'm not sure of the security complications of this, but if you're running a non-privledged user (e.g. non-root, non-wheel) you should be fine. The other ttys can be used to login root.
All that's left is to edit ~/.bash_profile and have X start whenever the login is initiated. Use this syntax:
Code: | export FOO=`tty`
export BAR=`echo ${FOO:5} | sed s/[0-9]//`
if [ "`echo ${BAR%/}`" != "pts" ]
then
exec startx
fi
unset FOO
unset BAR |
There are, however, some severe limitations to this. If <username> ever logs on to a tty (e.g. not a virtual terminal) he'll start X. Not good if you plan on logging on to more than one tty. That said, it also doesn't work very well under a multi user setup. Basically a quick and dirty hack. Hope this helps.
edit: messed up the tty detection code in the startx script.
edit2: made it so we can have lots and lots of terms. _________________ word.
Last edited by madmango on Sun Nov 28, 2004 8:46 pm; edited 4 times in total |
|
Back to top |
|
|
Gogiel Guru
Joined: 11 Nov 2004 Posts: 347
|
Posted: Sun Nov 28, 2004 3:09 pm Post subject: |
|
|
madmango wrote: | There are WAY easier ways to do this then to have to emerge gdm. For example, on my arcade machine, I don't want to have the gnome libraries installed. So I don't want to use gdm or kdm, and xdm can't do autologin. So we need to login without a X login manager, and then start X once we're logged in.
(...)
|
Well it doesn't work as good. If i want to open two aterm windows i see in 2nd:
Code: |
Fatal server error:
Server is already active for display 0
If this server is no longer running, remove /tmp/.X0-lock
and start again.
Please consult the The X.Org Foundation support
at http://wiki.X.Org
for help.
|
|
|
Back to top |
|
|
madmango Guru
Joined: 15 Jul 2003 Posts: 507 Location: PA, USA
|
Posted: Sun Nov 28, 2004 4:00 pm Post subject: |
|
|
Hmm. Interesting. I will look into this.
You're getting that because the second aterm is indeed not /dev/pts/0, so it's trying to start another X server. If you replace the earlier code with this, you should be fine for the first 256 [a|E]terms, which should be more than enough. You can add more terms by changing the number that sed looks for, but you'll only increase the startup time (albiet _slightly_) for each term.
Code: |
export FOO=`tty`
export BAR=`echo ${FOO:5} | sed s/[0-255]//`
if [ "`echo ${BAR%/}`" != "pts" ]
then
exec startx
fi
unset FOO
unset BAR
|
_________________ word. |
|
Back to top |
|
|
ag_x Tux's lil' helper
Joined: 11 Jun 2004 Posts: 142 Location: Self Sarkarm.
|
Posted: Sun Nov 28, 2004 5:23 pm Post subject: |
|
|
This method works for me. |
|
Back to top |
|
|
Gogiel Guru
Joined: 11 Nov 2004 Posts: 347
|
Posted: Sun Nov 28, 2004 6:36 pm Post subject: |
|
|
madmango wrote: | Hmm. Interesting. I will look into this.
You're getting that because the second aterm is indeed not /dev/pts/0, so it's trying to start another X server. If you replace the earlier code with this, you should be fine for the first 256 [a|E]terms, which should be more than enough. You can add more terms by changing the number that sed looks for, but you'll only increase the startup time (albiet _slightly_) for each term.
Code: |
export FOO=`tty`
export BAR=`echo ${FOO:5} | sed s/[0-255]//`
if [ "`echo ${BAR%/}`" != "pts" ]
then
exec startx
fi
unset FOO
unset BAR
|
|
Still doesn't help. Now i can open 3 aterms |
|
Back to top |
|
|
madmango Guru
Joined: 15 Jul 2003 Posts: 507 Location: PA, USA
|
Posted: Sun Nov 28, 2004 7:44 pm Post subject: |
|
|
Gogiel wrote: |
Still doesn't help. Now i can open 3 aterms |
That makes absolutely no sense at all.
Sigh. hold on. I'll figure this out. _________________ word. |
|
Back to top |
|
|
madmango Guru
Joined: 15 Jul 2003 Posts: 507 Location: PA, USA
|
Posted: Sun Nov 28, 2004 8:47 pm Post subject: |
|
|
OK.
It currently won't work for anything more than /dev/pts/9, which is the tenth virtual terminal. Change [0-255] to [0-9]. The reason for this is becuase it chops strings off by the number of characters, and when you have 10, it has one extra character on the end. I could easily adapt this for more than ten terms, but for me that's unreasonable and I'm much too lazy. _________________ word. |
|
Back to top |
|
|
Gogiel Guru
Joined: 11 Nov 2004 Posts: 347
|
Posted: Mon Nov 29, 2004 1:51 pm Post subject: |
|
|
I've got other idea. I'm not Bash guru, so it can have bugs
Create file /var/autologin/variable.txt
Code: | mkdir /var/autologin;touch/var/autologin/variable.txt; chmod 775 /var/autologin/variable.txt
|
Now we'll add that line to /etc/conf.d/local.start:
Code: | echo "1" > /var/autologin/variable.txt |
It'll make that at startup file /var/autologin/variable.txt will have inside 1.
Next we'll write a script /var/autologin/script.sh.
Code: |
#!/bin/bash
#/var/autologin/script.sh
FILE="/var/autologin/variable.txt"
VAR=`cat $FILE`
if [ $VAR = 1 ] # i'm not sure that's good.
then
echo "0" > $FILE
/usr/X11R6/bin/startx
fi
|
Now just add one line to .bash_profile
Code: | echo "sh /var/autologin/script.sh" >> ~/.bash_profile |
What do you think? |
|
Back to top |
|
|
madmango Guru
Joined: 15 Jul 2003 Posts: 507 Location: PA, USA
|
Posted: Mon Nov 29, 2004 8:46 pm Post subject: |
|
|
Looks good, but why are you using a file? It could just as easily work with a variable. export and echo are your friends.
And you'd still have to use my method for auto-logging in the user; all this does is auto-start x. So... combination of the two. _________________ word. |
|
Back to top |
|
|
dilandau Guru
Joined: 24 May 2003 Posts: 485 Location: germany
|
Posted: Sat Dec 04, 2004 6:58 pm Post subject: |
|
|
what about thisone:
rc.local:
Code: |
echo "Autologin of user <username>"
cd /home/<username>
su - <username>
|
~/.bash_profile:
Code: |
if ["`tty`" = "/dev/console" -o "`tty`" = "/dev/tty0"]
then
startx
fi
|
fails:
no rx.local file is executed on my gentoo system
su - <user>says -bash: [/dev/pty/s1: No such file or directory
ok, i get that error message but it works if the "if ... fi" condition with the console read is removed from the profile. alternatively the device node can be made accesible by users with chmod. no idea why i need a check here. if i log in from annother terminal i want x, too. if it cant start x, its ok if it display an error. _________________ gentoo linux - amd duron stalebred 1600 - elsa gladiac 311 (nvidia) - elitegroup k7s5a (sis, lan) - 256mb ram - wintv pci fm - airstar2 dvb-t pci - ide cdwriter - hp psc 1110 |
|
Back to top |
|
|
alexrait1 n00b
Joined: 26 Nov 2004 Posts: 4
|
|
Back to top |
|
|
dilandau Guru
Joined: 24 May 2003 Posts: 485 Location: germany
|
Posted: Sun Dec 05, 2004 9:53 am Post subject: |
|
|
why write a c program when su can do it for you:
su - <username>
user may keep his password because allmighty su can log him in without.
there's but the question, what happens if user logs out? will then ther ebe immediatley a root access to teh system? no! the login is done from
/etc/conf.d/local.start
after logging out the user sees the login: prompt or even a shutdown can be initiated fromthat file after the su. then system will go down if the user logs out and only root (if logging in extra) can change that.
in my case also the line in .bash_profile, where the $DISPLAY is checked, refuses to work. i simply have the lines
startxfce4
exit
in the .bash_profile. that works and if a terminal is opened under x, everything seems normal. the exit command drops back to the local.start script after user logs out via click on the controlpanel in xfce4. the local.start script then initiates a shutdown -h now.
i'm only curious why the su command, as used above, work but also prints out that user has no .bashrc or somethign like that (?). _________________ gentoo linux - amd duron stalebred 1600 - elsa gladiac 311 (nvidia) - elitegroup k7s5a (sis, lan) - 256mb ram - wintv pci fm - airstar2 dvb-t pci - ide cdwriter - hp psc 1110 |
|
Back to top |
|
|
dilandau Guru
Joined: 24 May 2003 Posts: 485 Location: germany
|
Posted: Mon Dec 06, 2004 12:15 pm Post subject: |
|
|
to log any user in without password:
Code: | login <username> -f |
see man login
so for gentoo make the changes to /etc/inittab as dwxcribed above (the script may even contain a shutdown -h now after the login to take system down when unser logs out) and the .bash_profiel can look like:
Code: | #!/bin/bash
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/vc/1 ]; then
startxfce4 -- -dpi 100
exit
|
_________________ gentoo linux - amd duron stalebred 1600 - elsa gladiac 311 (nvidia) - elitegroup k7s5a (sis, lan) - 256mb ram - wintv pci fm - airstar2 dvb-t pci - ide cdwriter - hp psc 1110 |
|
Back to top |
|
|
patroclo7 n00b
Joined: 28 Feb 2004 Posts: 68
|
Posted: Tue Dec 07, 2004 4:36 am Post subject: |
|
|
A nice app in order to autologin on console is qlogin. It is not in portage, but it is very ease to set up it and it works like a charm. You can download qlogin in freshmeat.net |
|
Back to top |
|
|
dilandau Guru
Joined: 24 May 2003 Posts: 485 Location: germany
|
Posted: Tue Dec 07, 2004 10:22 am Post subject: |
|
|
is there a reason not to use su to autologin someone?
after that line the next line can be what is to be done when the user logs out, e.g. taking teh system down and turn off. _________________ gentoo linux - amd duron stalebred 1600 - elsa gladiac 311 (nvidia) - elitegroup k7s5a (sis, lan) - 256mb ram - wintv pci fm - airstar2 dvb-t pci - ide cdwriter - hp psc 1110 |
|
Back to top |
|
|
enrique Guru
Joined: 03 Sep 2002 Posts: 342 Location: Denmark
|
|
Back to top |
|
|
G|N| Tux's lil' helper
Joined: 26 Feb 2004 Posts: 138 Location: Turnhout (Belgium)
|
Posted: Tue Feb 15, 2005 3:44 pm Post subject: |
|
|
i tried that one and it logs in my user very well, but freevo doesn't start at all.
this is what i get
Code: | pc-05 login: root (automatic login)
PAM-env[10227]: Unknown PAM_ITEM: <DISPLAY>
login[10227]; PAM pam_putenv: delete non-existent entry: DISPLAY
PAM-env[10227]: Unknown PAM_ITEM: <XAUTHORITY>
login(pam_unix)[10227]: session opened for user root by (uid=0)
|
and then the boot process continues but my user is logged in.
this is what is in my bash_profile:
Code: |
case "`tty`" in
/dev/tty1) clear && freevo -fs & >/dev/null;
esac
|
any help? |
|
Back to top |
|
|
enrique Guru
Joined: 03 Sep 2002 Posts: 342 Location: Denmark
|
Posted: Tue Feb 15, 2005 9:05 pm Post subject: |
|
|
The solution provided in the freevo wiki did not work for me either. So I use the first part, i.e. use mingetty, then I have the following in my ~/.bash_profile :
And startx reads my ~/.xinitrc which contains:
Code: | #!/bin/bash
nvidia-settings -l
xset s noblank
xset s off
xset -dpms
exec freevo |
_________________ Kind regards, enrique
Workstation,HTPC,Powerbook |
|
Back to top |
|
|
G|N| Tux's lil' helper
Joined: 26 Feb 2004 Posts: 138 Location: Turnhout (Belgium)
|
Posted: Wed Feb 16, 2005 5:01 pm Post subject: |
|
|
that seems to work, but before X will start, i have to do ctrl + alt + F7 and then x will appear.
is there a way to swith to tty7 in console? |
|
Back to top |
|
|
enrique Guru
Joined: 03 Sep 2002 Posts: 342 Location: Denmark
|
Posted: Wed Feb 16, 2005 5:05 pm Post subject: |
|
|
strange... if I issue startx on tty1 it will switch to X automatically _________________ Kind regards, enrique
Workstation,HTPC,Powerbook |
|
Back to top |
|
|
G|N| Tux's lil' helper
Joined: 26 Feb 2004 Posts: 138 Location: Turnhout (Belgium)
|
Posted: Wed Feb 16, 2005 5:33 pm Post subject: |
|
|
yes with me also, but i think that it's a problem that hdparm still has to be loaded after init3 so there still appaer messages on tty1 and that's why it doesn't change to tty7 (just what i guess that the problem could be) |
|
Back to top |
|
|
|