- 论坛徽章:
- 1
|
Automatic login at boot time on Solaris 2.x
Write a script that sets appropriate envoronment variables, opens
stdin
and stdout and stderr, and does whatever 'init' used to do for
'getty'.
Call this program from inside 'inittab' with an appropriate label and
at
an appropriate level.
I ended up creating the following entry in /etc/inittab which calls the
script that follows.
mp:34:wait://auto_login >/dev/console
2/dev/console
set USER =
# Verify that our user exists.
set exists = `ypmatch $USER passwd >& /dev/null`
if ( "$exists" == "" ) then
set exists = `grep "^^$USER" /etc/passwd`
if ( "$exists" == "" ) then
echo "Could not locate $user in either the NIS passwd map or"
echo "/etc/passwd. Without this user, the SW loaded"
echo "in ${HOME} cannot run."
echo "Please check that the installation completed successfully."
exit 1
endif
endif
# see if dtlogin session is already running - if so stop it
set dtrunning = `ps -eaf | grep dtlogin | grep -v grep | head -1 | awk '{
print $2 }'`
if ( "$dtrunning" != "" ) then
/etc/init.d/dtlogin stop
endif
# The following line changes the ownership and mode of files (like /dev/fbs
# and /dev/kbd) that OpenWindows uses. By default, these files have a
# permission of 0600 and are owned by root. Normally, login(1) sets these
# permissions and modes however... as usual we are not normal. This is
# necessary for OpenWindows to run for a non-root user.
#
/usr/bin/chown $USER /dev/console /dev/kbd /dev/fbs/* /dev/sound/*
/dev/mouse >& /dev/null
# Now launch OpenWindows as the non-root user
# Note that this will cause the error message "can't access tty - no job
control for
# this shell" when the program runs. This is normal and will not cause any
problems
# with running the system.
su - $USER
# Done.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/894/showart_64051.html |
|