LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 03-08-2013, 11:35 AM   #1
MPH426
LQ Newbie
 
Registered: Feb 2013
Posts: 7

Rep: Reputation: Disabled
Customizable runlevel 3 auto login no gdm howto on newer OS releases.


Hello all,

I've been searching for couple of days now for a way to auto login a user with little luck on finding what I want. I'm posting this in hopes that someone may find it useful.

A little background:
I have a purpose built computer to collect coordinate measurement data from the serial port and create csv files from it. It runs strictly in console mode, runlevel 3. It sits on the shop floor so I didn't want the operators to have access to the OS. So, I wanted a dedicated non-authoritative user to auto login and run the program. This was quite easy in older OS releases. Now not so easy to figure out.

Since the data collection program is spawned from their .profile as soon as they attempt to logout, they are logged back in and the program restarts. With this, I'm not too worried about security.

Search results:
Almost everything I saw wanted to change the tty.conf file's statement to include autologin for the user. This works, but logs the user in on all 6 ttys. I needed at least one open tty to login if there was a problem. Not to mention I really didn't want to have 6 instances of the program running.

Here's what I've come up with:
First, there's no need to change the tty.conf. Second, create a .conf file for each tty you'd like to customize. I've tried to include multiple users in a single conf file, with no luck. I think this is due to the way the initctl program works.

Standard tty.conf:
Code:
# tty - getty
#
# This service maintains a getty on the specified device.

stop on runlevel [S016]

respawn
instance $TTY
exec /sbin/mingetty $TTY
userx.conf
Code:
# tty - getty
#
# This service maintains a getty on the specified device.

stop on runlevel [S016]

respawn
instance $TTY

exec /sbin/mingetty --autologin userx $TTY
Standard start-ttys.conf
Code:
#
# This service starts the configured number of gettys.

start on stopped rc RUNLEVEL=[2345]

env ACTIVE_CONSOLES=/dev/tty[1-6]
env X_TTY=/dev/tty1
task
script
  . /etc/sysconfig/init
  for tty in $(echo $ACTIVE_CONSOLES) ; do
  [ "$RUNLEVEL" = "5" -a "$tty" = "$X_TTY" ] && continue
    initctl start tty TTY=$tty
  done
end script
Here's were it gets good.
Modified start-ttys.conf
Code:
#
# This service starts the configured number of gettys.

start on stopped rc RUNLEVEL=[2345]

env ACTIVE_CONSOLES=/dev/tty[1-6]
env X_TTY=/dev/tty1
task
script
  . /etc/sysconfig/init
  for tty in $(echo $ACTIVE_CONSOLES) ; do
    [ "$RUNLEVEL" = "5" -a "$tty" = "$X_TTY" ] && continue
    num=`basename "$tty"`
    case $num in
      tty1) initctl start userx TTY=$tty ;;
      tty6) initctl start tty TTY=$tty ;;
    esac
  done
end script
I use basename to strip off the slashes to make it easier to work with. The case statement is were the work gets done. I have tty1 logging in as userx, and tty6 starting a normal tty. You could change the tty6 in the case statement to * and all ttys except tty1 will start normally.
Code:
*) initctl start tty TTY=$tty ;;
As you can see there's a good deal of flexability in how you want it to start now.

Hope this helps

MPH426

Last edited by MPH426; 03-08-2013 at 11:39 AM. Reason: typo
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Debian Live, howto disable auto-login in gnome and in text shells (ctrl-alt 1/7) friendship7 Debian 1 01-26-2007 09:38 AM
auto login, howto? hongxing Linux - Software 4 10-12-2005 03:52 AM
Passwordless gdm login howto fannymites Linux - Software 5 04-03-2005 10:18 PM
gdm desktop auto login vampire Janus Linux - Software 1 10-26-2004 11:02 PM
Graphical Auto-Login without using KDM or GDM soda Linux - General 7 12-01-2002 12:57 PM


All times are GMT -5. The time now is 06:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration