The Implementation

Team-Fly    

Solaris™ Operating Environment Boot Camp
By David Rhodes, Dominic Butler
Table of Contents
Chapter 5.  Shells


This section contains the shell start-up files that we will be using on each of our systems. They are designed so that they will be identical on every system on our networks so that we don't have to manage them individuallywe can make a change on one server and then copy the file to all the others. This also means that when we build new servers in the future, we can have a standard set of profiles to install, rather than having to perform a piece of customization for each new server.

/Etc/profile

This file is executed for all users at login time. We have used it to set environment variables that all users will share. If users require anything different or additional to this file it can be specified in their own profile, which is located in their home directory.

In this system-wide profile we start off by using the trap command to prevent users from breaking out of the profile before it has set their environment. This could be a potential security loophole if we didn't include it.

We also have a stab at setting the user's terminal type correctly. In this case, we have assumed that if you logged in on the system console you are using a Sun color terminal, or if you have logged in from any other source you are using a vt220 emulator. Users that prefer to use a different emulator or terminal (e.g., an X station) can set the variable TERM in their own profile.

The next section of code ensures that if users are using a POSIX-compliant shell, then we will display the current message of the day (stored in /etc/motd) and display whether they have mail or not. If a file called .hushlogin exists, then we skip these.

The final section sets up environment variables. We ensure that the user has a PATH so the user can run Solaris commands. We set the prompt to include the host name to help make sure the user doesn't run the wrong command on the wrong host (which we've all done at some point!). Then we set the umask so that users can create files with sensible permissions.

We now unset the trap so users can break out of the login process if they like:

 # The profile that all logins get before using # their own .profile # The next line will prevent users from breaking out # of the profile before it has finished. trap "" 2 3 if [ "$TERM" = "" ] then   TTY=`tty`   if [ "$TTY" = "/dev/console" ]   then     TERM=sun-cmd   else     TERM=vt220   fi   export TERM fi # Login and -su shells get /etc/profile services # -rsh is given its environment in its .profile case $0 in   -sh | -ksh | -jsh)     if [ ! -f .hushlogin ]     then       /bin/cat /etc/motd       /bin/mail -E       case $? In         0)           echo "You have new mail."           ;;         2)           echo "You have mail."           ;;       esac     fi esac # Set a variable to hold the location of our own system # utilities, though we won't add it to the path here as # that would make it available to all users. LOCAL_UTILS=/usr/local/utilities export LOCAL_UTILS PATH="/bin:/usr/sbin:/usr/local/bin:" PS1="${HOSTNAME}$ " Export PATH PS1 # Set the umask to give write permissions to owner # and read to group and others umask 022 # Allow users to break out now trap 2 3 

Root User's .profile

This profile is just used for the root user. It sets the prompt to include a hash mark rather than a dollar sign to remind you that you are logged in as root and it also adds directories containing administrative commands to the PATH. You will see that we have also added the bin directory that contains our own scripts. These would not be added to the PATH of an ordinary user, who would not have permission to perform administrative tasks.

 # This is the profile for the root user. # Set the shell prompt to remind us we are root: PS1="${HOSTNAME}# " # Ensure we can run our local system utilities: PATH=${PATH}:$LOCAL_UTILS/bin:/etc export PATH PS1 

Other Users' .profile

This is the profile that is assigned to all standard users. It is placed in the home directory of each user.

 # .profile for standard users # If users have their own bin directory, add it to their PATH: if [ -d "$HOME/bin" ] then    PATH="$PATH:$HOME/bin" fi # Set the backspace key for erase: stty erase ^h # Create any local aliases: alias ll="ls -l" alias li="ls -li" alias lr="ls -lrt" alias cx="chmod +x" 

    Team-Fly    
    Top
     



    Solaris Operating Environment Boot Camp
    Solaris Operating Environment Boot Camp
    ISBN: 0130342874
    EAN: 2147483647
    Year: 2002
    Pages: 301

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net