Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Auto-Login on certain ttys [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
guyfromcanada
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jul 2005
Posts: 85
Location: British Columbia, Canada

PostPosted: Mon Jul 10, 2006 4:26 am    Post subject: Auto-Login on certain ttys [SOLVED] Reply with quote

I hope this hasn't been asked before. I've recently started to do almost everything from the shells, rarely using X anymore. I was wondering if it was possible to have certain ttys log in automatically as certain users and start up certain programs. For instance, I want tty1 to start as user1, running screen with mocp and mc. Then I want tty2 to start as user1 running screen with tmsnc, pine, and elinks, and similar for tty3, etc... How can someone set that up?

Thanks,
Nathan


Last edited by guyfromcanada on Sat Sep 30, 2006 12:52 am; edited 1 time in total
Back to top
View user's profile Send private message
Sourcecode
Guru
Guru


Joined: 25 Apr 2005
Posts: 392
Location: Germany, Kerpen in sew of Cologne

PostPosted: Mon Jul 10, 2006 4:30 am    Post subject: Reply with quote

Example : Spawn a 2 Shells with user "Carl", one shell launchs top, and one shall watching a logfile:

Log in with your Username into the X-Server (Carl as example)

Put this in your Autostart ( from your WM ) :

xterm -e top&
xterm -e tail -f /home/carl/somelogfile.txt
_________________
Es gibt bloss eins, was wichtig ist: dass man sterben muss.

Suicide is man's way of telling God, "You can't fire me - I quit."

no one gets out here alive....
Back to top
View user's profile Send private message
guyfromcanada
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jul 2005
Posts: 85
Location: British Columbia, Canada

PostPosted: Mon Jul 10, 2006 4:35 am    Post subject: Reply with quote

Wow, fast reply. Sorry, I should've been more clear. I don't want to use X, at all. Like I want from boot to be logged in with screen with mocp and mc started in tty1 (Alt+F1), screen with tmsnc, pine, and elinks in tty2 (Alt+F2), etc...

Any Ideas?
Thanks,
Nathan
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Fri Sep 01, 2006 3:09 am    Post subject: Reply with quote

Nathan,
Did you get this working? Im looking to do something very similar.
Back to top
View user's profile Send private message
guyfromcanada
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jul 2005
Posts: 85
Location: British Columbia, Canada

PostPosted: Fri Sep 01, 2006 4:52 am    Post subject: Reply with quote

nianderson,

No, I did not. And I really wish I could. I've googled it for a long time, checked other forums, can't find anything. And now I would like to have it more than ever, as I rarely use X anymore, and would like to have everything set up right at boot.
Sorry about that, maybe somebody has a solution.

--
Cheers,
Nathan
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Fri Sep 01, 2006 12:17 pm    Post subject: Reply with quote

I think you just need to edit your /etc/inittab and replace getty with what you would like to run. If you want to run something as a user then just make sure you stick su - username in front of it.

I think Im going to give that a shot today. I know its possible ive seen it on other setups.



Nick
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Fri Sep 01, 2006 5:49 pm    Post subject: Reply with quote

Yep you just need to edit /etc/inittab

look for the first agetty line.

you need to emerge mingetty and then do something like this
Code:

 1:12345:respawn:/sbin/mingetty --noclear --autologin username tty1


HTH

Nick
Back to top
View user's profile Send private message
guyfromcanada
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jul 2005
Posts: 85
Location: British Columbia, Canada

PostPosted: Thu Sep 21, 2006 12:05 am    Post subject: Reply with quote

Alright, here's what I've got.

I haven't rebooted since installing mingetty, so I haven't tested that yet. But I'm trying to get certain things to execute when I log in, like screen and things like that.

So here's my .bashrc:

Code:
exec /usr/bin/ttytest


and in /usr/bin/ttytest I have:

Code:
function get_tty
{
    if [ notset.$DISPLAY == notset. ]
    then
      ttyname="$(tty |  sed -e 's/.*\([0-9]\)/\1/')"
    fi
}

function startup
{
    get_tty
    if [ $ttyname == "1" ]
    then
      echo "tty1"
    else
      echo "not tty1"
    fi
}

startup


I ran env-update, and source /etc/profile, just to be sure.
I did a chmod a+x to the file, and ran it in fluxbox. and sure enough, the output was "not tty1". which is what I expected. then I ran it in tty1. and the output was "tty1", again as expected. so in tty1, I logged out, then logged in again, and I got the standard:

Code:
login(pam_unix)[8003]: session opened for user root by (uid=0)
Last login: Wed Sep 20 16:46:41 2006 on tty1
login[8002]: ROOT LOGIN  on  'tty1'
localhost ~ #


what am I doing wrong? should I put it in bash.profile? how can I fix this?

Cheers,
Nathan
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Thu Sep 21, 2006 12:29 am    Post subject: Reply with quote

Nathan,

I use this to run hpl as a specific user on a tty as a node boots. Is this what your trying to do? Im sure you can replace that with a screen command and have a nifty screenrc that runs everything else.
Code:

c2:2345:once:/bin/su teamhpc /home/teamhpc/Linux_OPTERON_FBLAS/hpl-single.sh localhost
Back to top
View user's profile Send private message
guyfromcanada
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jul 2005
Posts: 85
Location: British Columbia, Canada

PostPosted: Mon Sep 25, 2006 3:21 am    Post subject: Reply with quote

Alright, getting closer.

So in my inittab, I have:
Code:
# TERMINALS
c1:12345:once:/bin/su root /root/screen1.sh tty1 linux
c2:2345:once:/bin/su root /root/screen2.sh tty2 linux
c3:2345:once:/bin/su root /root/screen3.sh tty3 linux
c4:2345:once:/bin/su root /root/screen4.sh tty4 linux
c5:2345:once:/bin/su root /root/screen5.sh tty5 linux
c6:2345:once:/bin/su root /root/screen6.sh tty6 linux


and in /root/screen[n].sh I have:
Code:
exec /usr/bin/screen -c ~/.screenrc[n]


then, in ~/.screen[n] I have:
Code:
screen -t MAIL        0 pine
screen -t MSN         1 msn
screen -t GOOGLE      2 elinks http://www.google.com

..or whatever I want to start in that session of screen. Yeah, I know it's really round-about, but after a ot of trial and error, it got me the closest to where I want to be. But now when I boot up, I get some messed up thing. First of all, it's all in tty1. Second, it's all messed up instances, sometimes they overlap a bit, and it's almost impossible to navigate between them. So, can somebody help me out? I'm sure someone will see a fault in my n00b attempt at writing configs. Thanks in advance, and thanks for all of your help so far.

Nathan
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Mon Sep 25, 2006 1:45 pm    Post subject: Reply with quote

Quote:

and in /root/screen[n].sh I have:
Code:
exec /usr/bin/screen -c ~/.screenrc[n]


Try this

Code:

echo $*
sleep 30
  exec /usr/bin/screen -c ~/.screenrc[n]
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Mon Sep 25, 2006 2:37 pm    Post subject: Reply with quote

You know I am doing something very similar. I have it setup a little different.

I have the user setup to login automattically in inittab
Code:

c1:12345:respawn:/sbin/mingetty --autologin root tty1


Then I have a .bash_profile that detects which tty the login was on.
Code:

# bash_profile
# Author: Nick Anderson
# This bash_profile launches the burn options menu
#       if the users tty = 1. This allows us to only
#       present the menu on the first login screen and
#       only once ... as long as no one logs out of tty1
#       and logs back in.

# Get current tty
TTY=$(basename $(tty))
echo "You are currently connected to $TTY"
if [ $TTY == "tty1" ]
        then
        #Execute Burnin Option Menu
        /root/scripts/burn-menu
fi

then depending on the tty I launch another script see the Burnin option memu above. That basically is just a menu to select which screenrc to launch screen with. You could just stick your screen -c /path /to/config in place of the burnin option menu that I have above. See how that works out for you.
Back to top
View user's profile Send private message
guyfromcanada
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jul 2005
Posts: 85
Location: British Columbia, Canada

PostPosted: Sat Sep 30, 2006 12:51 am    Post subject: Reply with quote

Hey nianderson

That worked. Thanks a lot for your help. I edited your script to be:
Code:
if [ $TTY == "tty1" ]
        then
        #Execute Screen
        /usr/bin/screen -c ~/.screenrc1
fi

then to continue on:
Code:
if [ $TTY == "tty2" ]
        then
        #Execute Screen
        /usr/bin/scree -c ~/.screenrc2
fi

etc.
Thanks again for all of your time. It turned out really nicely.

Nathan
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Sat Sep 30, 2006 2:10 am    Post subject: Reply with quote

Glad I could help :)
Back to top
View user's profile Send private message
mikegpitt
Advocate
Advocate


Joined: 22 May 2004
Posts: 3224

PostPosted: Thu Apr 05, 2007 6:48 pm    Post subject: Reply with quote

Exactly what I was looking for too.. thanks!
Back to top
View user's profile Send private message
swimmer
Veteran
Veteran


Joined: 15 Jul 2002
Posts: 1330
Location: Netherlands

PostPosted: Thu Apr 05, 2007 8:07 pm    Post subject: Reply with quote

Does 'mingetty --auto-login' mean that you won't be asked for password authentication anymore?

Greetz
swimmer
Back to top
View user's profile Send private message
mikegpitt
Advocate
Advocate


Joined: 22 May 2004
Posts: 3224

PostPosted: Fri Apr 06, 2007 1:27 am    Post subject: Reply with quote

swimmer wrote:
Does 'mingetty --auto-login' mean that you won't be asked for password authentication anymore?
Yep just logs you in automatically, no questions asked.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum