Наши партнеры

UnixForum






Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

Исследуем процесс загрузки Linux

(C) В.А.Костромин, 2007
(версия файла от 6.10.2007 г.)


Назад Оглавление Вперед

Приложение 4. Скрипты из каталога /etc/profile.d/ системы Mandriva Free 2007.

Листинг 17. Файл /etc/profile.d/10lang.sh системы Mandriva Free 2007.1.

# /etc/profile.d/lang.sh - set i18n stuff

# revert special console/X11 settings if needed
if [ "$LC_SOURCED_CONSOLE" = 1 -a -n "$DISPLAY" ]; then
	unset LC_SOURCED
	unset LC_SOURCED_CONSOLE
elif [ "$LC_SOURCED_X11" = 1 -a -z "$DISPLAY" ]; then
	unset LC_SOURCED
	unset LC_SOURCED_X11
fi

# if GDM_LANG is defined that means a language other than the user default
# has been chosen trough gdm login for the session; so we define
# LC_SOURCED=1 to not read the system/user i18n files
if [ -n "$GDM_LANG" ]; then
    LANG="$GDM_LANG"
    LC_SOURCED=1
    export LC_SOURCED
fi

# only source one of the possible files, and in that order;
# if system wide and user config are mixed and different, umpredictable
# things will happen...
for langfile in $HOME/.i18n /etc/sysconfig/i18n ; do
	[ -f $langfile -a "$LC_SOURCED" != 1 ] && . $langfile && LC_SOURCED=1 && export LC_SOURCED
done    

if [ "$LC_SOURCED" = 1 ]; then
    if [ -n "$LANG" ] ; then
       [ "$LANG" = "C" ] && LANG="en_US"
       export LANG
    else
       unset LANG
    fi
    [ -n "$LANG" ] && export LANG || unset LANG
    [ -n "$LC_ADDRESS" ] && export LC_ADDRESS || unset LC_ADDRESS
    [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
    [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
    [ -n "$LC_IDENTIFICATION" ] && export LC_IDENTIFICATION || unset LC_IDENTIFICATION
    [ -n "$LC_MEASUREMENT" ] && export LC_MEASUREMENT || unset LC_MEASUREMENT
    [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
    [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
    [ -n "$LC_NAME" ] && export LC_NAME || unset LC_NAME
    [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
    [ -n "$LC_PAPER" ] && export LC_PAPER || unset LC_PAPER
    [ -n "$LC_TELEPHONE" ] && export LC_TELEPHONE || unset LC_TELEPHONE
    [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
    if [ -n "$LC_ALL" ]; then
       if [ "$LC_ALL" != "$LANG" ]; then
         export LC_ALL
       else
         unset LC_ALL
       fi
    else
       unset LC_ALL
    fi
    [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
    [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
    
    if [ -n "$RPM_INSTALL_LANG" ]; then
       export RPM_INSTALL_LANG
    else
       unset RPM_INSTALL_LANG
    fi

    # XIM and keyboard stuff
    [ -n "$ENC" ] && export ENC || unset ENC
    [ -n "$XIM" ] && export XIM || unset XIM
    [ -n "$XIM_PROGRAM" ] && export XIM_PROGRAM || unset XIM_PROGRAM
    [ -n "$XMODIFIERS" ] && export XMODIFIERS || unset XMODIFIERS
    [ -n "$_XKB_CHARSET" ] && export _XKB_CHARSET || unset _XKB_CHARSET
    [ -n "$GTK_IM_MODULE" ] && export GTK_IM_MODULE || unset GTK_IM_MODULE
    [ -n "$QT_IM_MODULE" ] && export QT_IM_MODULE || unset QT_IM_MODULE
    
    consoletype=$(/sbin/consoletype)

    [ -f /etc/init.d/mandrake_consmap ] && . /etc/init.d/mandrake_consmap

    unset SYSFONTACM SYSFONT

    # handling of special cases where localization is done
    # only on console or only on X11.
    # when launching an xdm-like program we are not yet in X11 (so
    # $DISPLAY is not defined) but obviously we will, so we check
    # also $DESKTOP which is defined before calling xdm-like program
    if [ -n "$DISPLAY" ]; then
	if [ "$X11_NOT_LOCALIZED" = "yes" ]; then
		LANGUAGE=C
		LC_SOURCED_X11=1
		export LC_SOURCED_X11
	fi
    elif [ -z "$DESKTOP" ]; then
	if [ "$CONSOLE_NOT_LOCALIZED" = "yes" ]; then
		LANGUAGE=C
		LC_SOURCED_CONSOLE=1
		export LC_SOURCED_CONSOLE
	fi
    fi
    
    if [ -n "$CHARSET" ]; then
	case $CHARSET in
	    8859-1|8859-2|8859-5|8859-8|8859-15|koi*)
                if [ "$TERM" = "linux" -a "$consoletype" = "vt" ]; then
                       echo -n -e '\033(K' 2>/dev/null > /proc/$$/fd/0
                fi
                ;;
        esac
    elif [ -n "$SYSFONTACM" ]; then
	case $SYSFONTACM in
	    iso01*|iso02*|iso05*|iso08*|iso15*|koi*|latin2-ucw*)
		if [ "$TERM" = "linux" -a "$consoletype" = "vt" ]; then
			echo -n -e '\033(K' 2>/dev/null > /proc/$$/fd/0
		fi
		;;
	esac
    fi
    if [ -n "$LANG" ]; then
      case $LANG in
    	*.utf8*|*.UTF-8*)
    	if [ "$TERM" = "linux" ]; then
    	    if [ "$consoletype" = "vt" ]; then
    	    	case $LANG in 
    	    		ja*) LANG=en_US.UTF-8 ;;
    	    		ko*) LANG=en_US.UTF-8 ;;
			si*) LANG=en_US.UTF-8 ;;
    	    		zh*) LANG=en_US.UTF-8 ;;
    	    		en_IN*) ;;
    	    		*_IN*) LANG=en_US.UTF-8 ;;
    	    	esac
		[ -x /bin/unicode_start ] && /sbin/consoletype fg && /bin/unicode_start $SYSFONT $SYSFONTACM
            fi
        fi
	;;
	*)
	if [ "$TERM" = "linux" ]; then
	    if [ "$consoletype" = "vt" ]; then
    	    	case $LANG in 
    	    		ja*) LANG=en_US ;;
    	    		ko*) LANG=en_US ;;
			si*) LANG=en_US ;;
    	    		zh*) LANG=en_US ;;
    	    		en_IN*) ;;
    	    		*_IN*) LANG=en_US ;;
    	    	esac
	    	[ -x /bin/unicode_stop ] && /sbin/consoletype fg && /bin/unicode_stop
	    fi
	fi
	;;
      esac
    fi
    [ -n "$LANGUAGE" ] && export LANGUAGE

fi
unset langfile

Листинг 18. Файл /etc/profile.d/10mandriva-release.sh системы Mandriva Free 2007.1.

. /etc/sysconfig/system
export META_CLASS

Листинг 19. Файл /etc/profile.d/alias.sh системы Mandriva Free 2007.1.

#!/bin/sh
# Linux-Mandrake configuration: Chmouel Boudjnah <chmouel@mandrakesoft.com>
#
# Common Aliases for a system.
#
# The Semantic is :
#	If exist a ~/.alias and the user hasn't specified a
#	LOAD_SYSTEM_ALIAS variables then don't do any system aliases
#	If there is no ~/.alias but the user has specified a
#	IGNORE_SYSTEM_ALIASES then don't do any system aliases.

[ -f ~/.alias ] && [ -z $LOAD_SYSTEM_ALIASES ] && return 0
[ -n "$IGNORE_SYSTEM_ALIASES" ] && return 0

if [ -f ~/.dir_colors ]; then
	eval `dircolors --sh ~/.dir_colors`
else
	eval `dircolors --sh /etc/DIR_COLORS`
fi

# Don't define aliases in plain Bourne shell
[ -n "${BASH_VERSION}${KSH_VERSION}${ZSH_VERSION}" ] || return 0

# default ls options
LS_OPTIONS="-F"

# this should be removed once the bug with ls and multibytes locales is fixed
[ -r /etc/profile.d/lang.sh ] && . /etc/profile.d/lang.sh
case "$LC_ALL$LC_CTYPE" in
    ja*|ko*|zh*) LS_OPTIONS="$LS_OPTIONS --show-control-chars" ;;
    *) if [ "`locale charmap`" = "UTF-8" ]; then
        LS_OPTIONS="$LS_OPTIONS --show-control-chars"
       fi ;;
esac

# emacs doesn't support color
if [ $TERM != "emacs" ];then
    LS_OPTIONS="$LS_OPTIONS --color=auto"
fi

alias ls="ls $LS_OPTIONS"

alias d="ls"                                                  
alias l="ls"       		# classical listing.
alias ll="ls -l"   		# List detailled. 
alias la='ls -a'     	# List all.               
alias lsd="ls -d */"		# List only the directory.
alias cd..="cd .."		
alias s="cd .."
alias p="cd -"

alias md="mkdir"
alias rd="rmdir"
alias cp="cp -i"
alias mv="mv -i"
alias rm="rm -i"

alias grep="grep --color"      # colored grep by default

# Size of a directory (by default Human Readable).
alias du='du -h'                              
                                              
# Size of a disk (by default Human Readable). 
# and don't probe supermount
alias df='df -h -x supermount'

Листинг 20. Файл /etc/profile.d/configure_keyboard.sh системы Mandriva Free 2007.1.

#!/bin/sh

# bash sets the $- variable, and puts 'c' in it if it is a non-interactive
# shell
# For other shells, I assume $- is not available
if [ "$SHELL" = "/bin/bash" ]; then
		if echo $- | grep 'c' >/dev/null; then
				return  #non-interactive
		fi
fi

# Run only in interactive sessions
if [ -n "$PS1" ]; then
    if [ -x /etc/sysconfig/keyboard ]; then
	. /etc/sysconfig/keyboard 2> /dev/null
    fi
    
    if [ -z "$BACKSPACE" ]; then
	# the code for Backspace key is arch-dependent.
	# FIXME: what really returns uname for non-PC machines ???
	case `uname -m`-`uname -p` in
	    i[3456789]86-*) BSNUM=14 ;;
	    *-amiga) BSNUM=65 ;;
	    m68k-atari) BSNUM=14 ;;
	    *-macintosh) BSNUM=51 ;;
	    mips-sun) BSNUM=43 ;;
	    *) BSNUM=999 ;;
	esac

	if [ "$BSNUM" != "999" ]; then
	    BACKSPACE=`dumpkeys 2> /dev/null | grep "^keycode  $BSNUM" | awk '{print $4}'`
	fi
    fi
    
    # BackSpace sends BackSpace
    if [ "$BACKSPACE" = "BackSpace" ]; then
    
	if tty --quiet ; then
	    : #stty erase '^H' &
	fi
    
	# xterm
	if [ "$TERM" = "xterm" -o "$TERM" = "xterm-color" ]; then
	    echo -en '\033[36h'
	fi
    
    # BackSpace sends Delete
    else
    
	if tty --quiet ; then
	    : #stty erase '^?' &
	fi
    
	# xterm
	if [ "$TERM" = "xterm" -o "$TERM" = "xterm-color" ]; then
	    echo -en '\033[36l'
	fi
    fi
    
    # activate keypad on xterm
    if [ "$TERM" = "xterm" -o "$TERM" = "xterm-color" ]; then
	# activate keypad
	echo -en '\033>'
    fi
fi

# ugly hack for an ugly bug
#killall -9 stty > /dev/null >& /dev/null

Листинг 21. Файл /etc/profile.d/gconf.sh системы Mandriva Free 2007.1.

if [ -z "$GCONF_TMPDIR" ]; then
	GCONF_TMPDIR=/tmp
	export GCONF_TMPDIR
fi

Листинг 22. Файл /etc/profile.d/glib20.sh системы Mandriva Free 2007.1.

## This caused GLib2 applications to convert filenames from 
## locale encoding to UTF-8. If the locale encoding is already
## UTF-8 then it makes no difference.

G_FILENAME_ENCODING="@locale"
export G_FILENAME_ENCODING

Листинг 23. Файл /etc/profile.d/inputrc.sh системы Mandriva Free 2007.1.

#!/bin/bash

test -f $HOME/.inputrc || export INPUTRC=/etc/inputrc
export LESS=-MM
test -f $HOME/.less || export LESSKEY=/etc/.less

Листинг 24. Файл /etc/profile.d/kde3.sh системы Mandriva Free 2007.1.

#!/bin/sh
alias kde="xinit /usr/bin/startkde"

Листинг 25. Файл /etc/profile.d/less.sh системы Mandriva Free 2007.1.

#!/bin/sh
CHARSET=$(locale charmap 2> /dev/null) 
case "$CHARSET" in 
       UTF-8) 
               export LESSCHARSET="${LESSCHARSET:-utf-8}" 
       ;; 
       * ) 
               export LESSCHARSET="${LESSCHARSET:-koi8-r}" 
       ;; 
esac
# Make a filter for less
export LESSOPEN="|/usr/bin/lesspipe.sh %s"

Листинг 26. Файл /etc/profile.d/mc.sh системы Mandriva Free 2007.1.

# Don't define aliases in plain Bourne shell
[ -n "${BASH_VERSION}${KSH_VERSION}${ZSH_VERSION}" ] || return 0
alias mc='. /usr/share/mc/bin/mc-wrapper.sh'

Листинг 27. Файл /etc/profile.d/menustyle.sh системы Mandriva Free 2007.1.

if [ "$META_CLASS" = "desktop" ]; then 
	MDV_MENU_STYLE=discovery 
else
	MDV_MENU_STYLE=mandriva
fi

[ -r /etc/sysconfig/menustyle ] && source /etc/sysconfig/menustyle
[ -r $HOME/.menustyle ] && source $HOME/.menustyle

if [ "$MDV_MENU_STYLE" = "discovery" -a "x$XDG_CONFIG_DIRS" = "x" ]; then
	XDG_CONFIG_DIRS=/etc/xdg/discovery:/etc/xdg
	export XDG_CONFIG_DIRS
fi

export MDV_MENU_STYLE

Листинг 28. Файл /etc/profile.d/msec.sh системы Mandriva Free 2007.1.

#---------------------------------------------------------------
# Project         : Mandriva Linux
# Module          : msec
# File            : msec.sh
# Version         : $Id: msec.sh,v 1.13 2005/09/08 09:27:30 flepied Exp $
# Author          : Yoann Vandoorselaere
# Created On      : Wed Feb 13 18:35:58 2002
# Purpose         : settings according to security level
#---------------------------------------------------------------

if [ -r /etc/sysconfig/msec ]; then
	. /etc/sysconfig/msec
fi

if [ `id -u` -ge 500 ]; then
    if [ -n "$UMASK_USER" ]; then
	umask $UMASK_USER
    else
	umask 022
    fi
else
    if [ -n "$UMASK_ROOT" ]; then
	umask $UMASK_ROOT
    else
	umask 002
    fi
fi

if [ -n "$SECURE_LEVEL" ]; then
    if [ "$SECURE_LEVEL" -le 1 ] && ! echo ${PATH} | fgrep -q :.; then
	export PATH=$PATH:.
    fi
fi

export SECURE_LEVEL

[ -n "$TMOUT" ] && type typeset > /dev/null 2>&1 && typeset -r TMOUT

# msec.sh ends here

Листинг 29. Файл /etc/profile.d/numlock.sh системы Mandriva Free 2007.1.

# Linux-Mandrake configuration.
#	ReLock the NumLock key if /etc/rc.d/init.d/numlock has been run.
#	This is needed because login resets the tty.

MY_TTY=`tty`
case $MY_TTY in
    /dev/tty[0-9]*)	[ -f /var/lock/subsys/numlock ] && setleds -D +num < $MY_TTY;;
esac
unset MY_TTY

Листинг 30. Файл /etc/profile.d/python.sh системы Mandriva Free 2007.1.

#!/bin/sh
if [ -f $HOME/.pythonrc.py ] ; then
	export PYTHONSTARTUP=$HOME/.pythonrc.py
else
	export PYTHONSTARTUP=/etc/pythonrc.py
fi

Листинг 31. Файл /etc/profile.d/qtdir3.sh системы Mandriva Free 2007.1.

# Set QTDIR for Bash shell
if [ -z "$QTDIR" ]; then
   export QTDIR="/usr/lib/qt3/"
fi

PATH=$PATH:$QTDIR/bin
export PATH

Листинг 32. Файл /etc/profile.d/screen.sh системы Mandriva Free 2007.1.

#!/bin/sh
# /etc/profile.d/screen.sh

if [ -z "$SCREENDIR" ]; then
    export SCREENDIR=$HOME/tmp
fi

Листинг 33. Файл /etc/profile.d/ssh-client.sh системы Mandriva Free 2007.1.

#!/bin/sh
# fix hanging ssh clients on exit

if [ -n "$BASH_VERSION" ]; then
	shopt -s huponexit
elif [ -n "$ZSH_VERSION" ]; then
	setopt hup
fi

Листинг 34. Файл /etc/profile.d/tmpdir.sh системы Mandriva Free 2007.1.

#!/bin/sh
# $Id$
# Set TMPDIR to ~/tmp and create it if directory not exist.

if [ -f /etc/sysconfig/system ];then
    . /etc/sysconfig/system
fi

SECURE_LEVEL=3			# default level without msec
if [ -f /etc/sysconfig/msec ];then
    eval `grep ^SECURE_LEVEL= /etc/sysconfig/msec | head -1`
fi

if [ "$SECURE_TMP" = "yes" -o "$SECURE_TMP" = "1" -o "$SECURE_TMP" = "YES" -o "$SECURE_LEVEL" -ge 2 ];then
    if [ -d ${HOME}/tmp -a -w ${HOME}/tmp ];then
	export TMPDIR=${HOME}/tmp
	export TMP=${HOME}/tmp
    elif mkdir -p ${HOME}/tmp >/dev/null 2>&1;then
	chmod 700 ${HOME}/tmp
	export TMPDIR=${HOME}/tmp
	export TMP=${HOME}/tmp
    else
	export TMPDIR=/tmp/
	export TMP=/tmp/
    fi
fi

Листинг 35. Файл /etc/profile.d/xhost.sh системы Mandriva Free 2007.1.

# Export Xauthority for users not for root.

if [ ! -z "$DISPLAY" -a -z "$SSH_TTY" ];then
	if [ "`id -u`" -gt 14 ];then
		if [ -z $XAUTHORITY ];then
		    export XAUTHORITY=$HOME/.Xauthority
		fi
	fi
fi

Назад Оглавление Вперед