jeudi 29 avril 2010

LINUX : Mes fichiers de config. part 1

Bon alors c'est simple. J'ai envie de garder une trace de certains fichiers de config et j'utilise ce blog pour le faire.

On commence par /etc/bash.bashrc


# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, overwrite the one in /etc/profile)
#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

########
COLOR_RED="\[\e[31;40m\]"
COLOR_GREEN="\[\e[32;40m\]"
COLOR_YELLOW="\[\e[33;40m\]"
COLOR_BLUE="\[\e[34;40m\]"
COLOR_MAGENTA="\[\e[35;40m\]"
COLOR_CYAN="\[\e[36;40m\]"

COLOR_RED_BOLD="\[\e[31;1m\]"
COLOR_GREEN_BOLD="\[\e[32;1m\]"
COLOR_YELLOW_BOLD="\[\e[33;1m\]"
COLOR_BLUE_BOLD="\[\e[34;1m\]"
COLOR_MAGENTA_BOLD="\[\e[35;1m\]"
COLOR_CYAN_BOLD="\[\e[36;1m\]"

COLOR_NONE="\[\e[0m\]"

promptFunc()
{
    PREV_RET_VAL=$?;
    PS1=""
   
    if test `whoami` != "root"
    then
        PS1="${debian_chroot:+($debian_chroot)}${COLOR_BLUE_BOLD}\u@${COLOR_GREEN_BOLD}\h${COLOR_NONE}:${COLOR_BLUE_BOLD}\w${COLOR_NONE}"
    else
        PS1="${debian_chroot:+($debian_chroot)}${COLOR_RED_BOLD}\u@${COLOR_GREEN_BOLD}\h${COLOR_NONE}:${COLOR_RED_BOLD}\w${COLOR_NONE}"
    fi

    #PS1="${PS1}"

    if test $PREV_RET_VAL -eq 0
    then
        PS1="${PS1}${COLOR_GREEN_BOLD}\\$ ${COLOR_NONE}"
    else
        PS1="${PS1}${COLOR_RED_BOLD}\\$ [Valeur de retour : ${PREV_RET_VAL}] ${COLOR_NONE}"
    fi
}

PROMPT_COMMAND=promptFunc


# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
#    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
#    ;;
#*)
#    ;;
#esac

# enable bash completion in interactive shells
#if [ -f /etc/bash_completion ]; then
#    . /etc/bash_completion
#fi

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found ]; then
    function command_not_found_handle {
            # check because c-n-f could've been removed in the meantime
                if [ -x /usr/lib/command-not-found ]; then
           /usr/bin/python /usr/lib/command-not-found -- $1
                   return $?
        else
           return 127
        fi
    }
fi
[[ -f "/etc/autopackage/paths-bash" ]] && . "/etc/autopackage/paths-bash"


On continue avec /etc/ntp.conf

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift


# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable


# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool:
server 0.debian.pool.ntp.org iburst dynamic


# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust


# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient
server 0.fr.pool.ntp.org
server 1.fr.pool.ntp.org
server 2.fr.pool.ntp.org
server 1.debian.pool.ntp.org
server 2.debian.pool.ntp.org
server 3.debian.pool.ntp.org
server canon.inria.fr
server chronos.cru.fr
server ntp.cs.strath.ac.uk
server bernina.ethz.ch
server ntps1-1.cs.tu-berlin.de
server ntps1-0.cs.tu-berlin.de
server ntps1-2.uni-erlangen.de
server time.ien.it
server ntp0.nl.net
server ntp1.nl.net
server ntp2.nl.net
server ntp.certum.pl
server vega.cbk.poznan.pl
server ntp2.ja.net
server ntpa2.kph.uni-mainz.de
server ntp.univ-lyon1.fr


Alors bon il faut encore s'assurer que l'heure reste corrècte. Normalement une contrôle de l'heure une fois par jour voir par semaine ou même moins suffit mais mon Ordi déconne grave et il perd sans cesse l'heure juste quand bien même il est en fonction !
Pour ça j'ai planifié une commande avec Crontab sur le compte Root. Tout simplement celle qui permet la synchronisation avec un serveur NTP.

# m h  dom mon dow   command
0 * * * * /usr/sbin/ntpdate -u 0.fr.pool.ntp.org


On continue avec /home/moncompte/.bashrc

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

########
COLOR_RED="\[\e[31;40m\]"
COLOR_GREEN="\[\e[32;40m\]"
COLOR_YELLOW="\[\e[33;40m\]"
COLOR_BLUE="\[\e[34;40m\]"
COLOR_MAGENTA="\[\e[35;40m\]"
COLOR_CYAN="\[\e[36;40m\]"

COLOR_RED_BOLD="\[\e[31;1m\]"
COLOR_GREEN_BOLD="\[\e[32;1m\]"
COLOR_YELLOW_BOLD="\[\e[33;1m\]"
COLOR_BLUE_BOLD="\[\e[34;1m\]"
COLOR_MAGENTA_BOLD="\[\e[35;1m\]"
COLOR_CYAN_BOLD="\[\e[36;1m\]"

COLOR_NONE="\[\e[0m\]"

#promptFunc()
#{
#    PREV_RET_VAL=$?;
#    PS1=""
#   
#    if test `whoami` != "root"
#    then
#        PS1="${debian_chroot:+($debian_chroot)}${COLOR_BLUE_BOLD}\u@${COLOR_GREEN_BOLD}\h${COLOR_NONE}:${COLOR_BLUE_BOLD}\w${COLOR_NONE}"
#    else
#        PS1="${debian_chroot:+($debian_chroot)}${COLOR_RED_BOLD}\u@${COLOR_GREEN_BOLD}\h${COLOR_NONE}:${COLOR_RED_BOLD}\w${COLOR_NONE}"
#    fi
#
#    #PS1="${PS1}"
#
#    if test $PREV_RET_VAL -eq 0
#    then
#        PS1="${PS1}${COLOR_GREEN_BOLD}\\$ ${COLOR_NONE}"
#    else
#        PS1="${PS1}${COLOR_RED_BOLD}\\$ [Valeur de retour : ${PREV_RET_VAL}] ${COLOR_NONE}"
#    fi
#}
########

# set a fancy prompt (non-color, unless we know we "want" color)
#case "$TERM" in
#xterm-color)
#    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
#    ;;
#*)
#    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
#    ;;
#esac

# Comment in the above and uncomment this below for a color prompt
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
#    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
#    ;;
#*)
#    ;;
#esac

#PROMPT_COMMAND=promptFunc

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

#if [ -f ~/.bash_aliases ]; then
#    . ~/.bash_aliases
#fi

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='ls --color=auto --format=vertical'
    #alias vdir='ls --color=auto --format=long'
fi

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

alias sauvegarde='rsync -ahv --stats --progress /home/eminomeneko/ /mnt/donnees/backup_Linux/'
function man2pdf()
{
    filename="$1"
    man -t ${filename} > man_${filename}.ps && ps2pdf man_${filename}.ps && rm -f man_${filename}.ps
}

export PATH=/usr/java/jre1.6.0_16/bin:$PATH


Voilà pour aujourd'hui