Add dia
[hvlinux.git] / stage1 / create-config-files
index ef723b5..b840c67 100755 (executable)
@@ -1,10 +1,6 @@
-#!/bin/sh
-set -o errexit
+#!/bin/bash
 
-# Reading system configuration informations, functions and package versions.
-source ../sysinfos
-source ../functions
-source ../packages-list
+source ../functions/main
 
 echo "Creating /etc/fstab"
 cat > ${LFS}/etc/fstab << "EOF"
@@ -13,25 +9,31 @@ cat > ${LFS}/etc/fstab << "EOF"
 EOF
 
 if [ -n "${BOOT_PARTITION}" ]; then
-    echo "${BOOT_PARTITION} /boot ext2 defaults 1 1" >> ${LFS}/etc/fstab
+    install -v -m755 -d ${LFS}/mnt/boot
+    echo "${BOOT_PARTITION} /mnt/boot auto ${PARTITION_MOUNT_OPTS} 0 0" >> ${LFS}/etc/fstab
 fi
 if [ -n "${SWAP_PARTITION}" ]; then
     echo "${SWAP_PARTITION} none swap sw 0 0" >> ${LFS}/etc/fstab
 fi
-echo "${LFS_PARTITION}  /                 reiserfs defaults,noatime 0 0" >> ${LFS}/etc/fstab
+echo "${LFS_PARTITION}  /                 auto ${PARTITION_MOUNT_OPTS} 0 0" >> ${LFS}/etc/fstab
 
 cat >> ${LFS}/etc/fstab << "EOF"
-/dev/cdrom        /media/cdrom      auto     ro,noauto,users  0 0
-/dev/dvd          /media/dvd        auto     ro,noauto,users  0 0
 proc              /proc             proc     defaults         0 0
 sysfs             /sys              sysfs    defaults         0 0
+tmpfs             /run              tmpfs    defaults,noatime 0 0
+tmpfs             /tmp              tmpfs    defaults,,noatime,mode=1777,size=_TMP_PARTITION_SIZE_ 0 0
 devpts            /dev/pts          devpts   gid=4,mode=620   0 0
 shm               /dev/shm          tmpfs    defaults         0 0
+
+/dev/dvd        /media/dvd      auto      noauto,ro,users
 EOF
 
-echo "Creating basic /etc/profile"
+sed -i -e "s!_TMP_PARTITION_SIZE_!${TMP_PARTITION_SIZE}!g" ${LFS}/etc/fstab
+
+echo "Creating basic /etc/profile and /etc/profile.d"
+install -v -m755 -d ${LFS}/etc/profile.d
 cat > ${LFS}/etc/profile << "EOF"
-#!/bin/sh
+#!/bin/bash
 # /etc/profile
 
 # System-wide environment and startup programs.
@@ -43,11 +45,15 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/tools/bin:/tools/sbin
 USER=`id -un`
 LOGNAME=$USER
 MAIL="/var/mail/$USER"
-HISTFILESIZE=1000
+
+# Don't put duplicate lines in the history.
+HISTCONTROL=ignoredups:ignorespace
+HISTFILESIZE=2000
 HISTSIZE=1000
+
 HOSTNAME=`hostname`
 EDITOR=_DEFAULT_EDITOR_
-CFLAGS="-pipe -O2"
+CFLAGS="_DEFAULT_CFLAGS_"
 CXXFLAGS=${CFLAGS}
 
 # Set default permissions when creating new files.
@@ -68,7 +74,7 @@ ulimit -c 0
 
 MANPATH=/usr/share/man:/usr/local/share/man
 
-LANG="en_US.UTF-8"
+LANG="en_US.utf8"
 
 # The sort order of ls output is affected by  the  locale  and
 # can  be  overridden  by the LC_COLLATE environment variable.
@@ -78,16 +84,27 @@ LANG="en_US.UTF-8"
 # LC_COLLATE equals en_US.ISO8859-1, then leading dots as well
 # as case are ignored in determining the sort order.
 LC_COLLATE=C
-################# LC_ALL=POSIX
 
-export PATH MANPATH LANG LC_COLLATE PS1 PS2 USER LOGNAME MAIL HISTFILESIZE HISTSIZE HOSTNAME EDITOR CFLAGS CXXFLAGS
+# If this is not set, some characters (quotes) are not displayed correctly:
+LC_CTYPE=C
+
+export PATH MANPATH LANG LC_COLLATE LC_CTYPE PS1 PS2 USER LOGNAME MAIL HISTFILESIZE HISTSIZE HOSTNAME EDITOR CFLAGS CXXFLAGS
+
+for script in /etc/profile.d/*.sh ; do
+    if [ -r ${script} ]; then
+        . ${script}
+    fi
+done
+
 EOF
 
 sed -i -e "s!_DEFAULT_EDITOR_!${DEFAULT_EDITOR}!g" ${LFS}/etc/profile
 
+sed -i -e "s!_DEFAULT_CFLAGS_!-pipe -O2 ${MARCH_FLAGS}!g" ${LFS}/etc/profile
+
 echo "Creating /etc/bashrc"
 cat > ${LFS}/etc/bashrc << "EOF"
-#!/bin/sh
+#!/bin/bash
 
 # /etc/bashrc
 
@@ -100,8 +117,18 @@ alias cp='cp -i'
 alias df='df -h'
 alias du='du -h -s'
 # --show-control-chars is for seeing international characters in filenames
-alias ls='ls -h --color=auto --show-control-chars'
+alias ls='ls -h --color=auto --show-control-chars --time-style=long-iso'
 eval $(dircolors --sh /etc/DIR_COLORS)
+alias grep='grep --color=auto'
+alias fgrep='fgrep --color=auto'
+alias egrep='egrep --color=auto'
+alias less='less -RFX'
+
+# Pour que la touche BACKSPACE fonctionne correctement lorsque Bash nous
+# demande une confirmation (quand on veut effacer un fichier par exemple).
+if tty --quiet ; then
+    stty erase '^H'
+fi
 
 # For some unknown reason bash refuses to inherit PS1 in some circumstances
 # that I can't figure out. Putting PS1 here ensures that it gets loaded every
@@ -117,48 +144,19 @@ eval $(dircolors --sh /etc/DIR_COLORS)
 if [ "$TERM" = "linux" ]; then
     #we're on the system console or maybe telnetting in
     export PS1="\u(\W)\$"
-    #export PS1="\[\e[32;1m\]\u@\H > \[\e[0m\]"
+elif [ -n "${SSH_CONNECTION}" ]; then
+    export PS1="\[\e]2;[\u]   \w\a\e[33;1m\]ssh \H >\[\e[0m\] "
 else
     #we're not on the console, assume an xterm
-    #export PS1="\[\e]2;\u@\H   \w\a\e[32;1m\]>\[\e[0m\] "
     export PS1="\[\e]2;[\u]   \w\a\e[32;1m\]>\[\e[0m\] "
 fi
-EOF
 
-echo "Installing /etc/DIR_COLORS"
-install -m644 ${SCRDIR}/misc/DIR_COLORS ${LFS}/etc/DIR_COLORS
-
-echo "Creating /etc/inputrc"
-cat > ${LFS}/etc/inputrc << "EOF"
-# Begin /etc/inputrc
-
-# Enable 8bit input
-set meta-flag On
-set input-meta On
-# Turns off 8th bit stripping
-set convert-meta Off
-# Keep the 8th bit for display
-set output-meta On
-
-# none, visible or audible
-set bell-style none
-
-# All of the following map the escape sequence of the value contained inside
-# the 1st argument to the readline specific functions
-"\eOd": backward-word
-"\eOc": forward-word
-# for linux console
-"\e[1~": beginning-of-line
-"\e[4~": end-of-line
-"\e[5~": beginning-of-history
-"\e[6~": end-of-history
-"\e[3~": delete-char
-"\e[2~": quoted-insert
-# for xterm
-"\eOH": beginning-of-line
-"\eOF": end-of-line
 EOF
 
+install -v -m644 ${SCRDIR}/misc/DIR_COLORS ${LFS}/etc
+
+install -v -m644 ${SCRDIR}/misc/inputrc ${LFS}/etc
+
 cat >> ${LFS}/etc/modules << "EOF"
 # /etc/modules: kernel modules to load at boot time.
 #
@@ -194,7 +192,7 @@ EOF
 cat > ${LFS}/etc/skel/.bashrc << "EOF"
 # ~/.bashrc
 
-# User specific aliases and functions
+# User bashrc
 # This file is executed each time an xterm window
 # is started.
 
@@ -203,6 +201,28 @@ if [ -f /etc/bashrc ]; then
        . /etc/bashrc
 fi
 
+# Source user aliases
+if [ -f ~/.bash_aliases ]; then
+    . ~/.bash_aliases
+fi
+
+EOF
+
+cat > ${LFS}/etc/skel/.bash_aliases << "EOF"
+# ~/.bash_aliases
+
+# User specific aliases
+
+alias hy='history'
+
+# GIT aliases
+alias gra='git rebase --abort'
+alias grc='git rebase --continue'
+alias gri='git rebase -i'
+alias gca='git commit --amend'
+alias vdc='vd --cached'
+alias gitk='gitk --all'
+
 EOF
 
 # Copy skeleton files to root user directory
@@ -215,11 +235,15 @@ cat > ${LFS}/etc/shells << "EOF"
 EOF
 chmod 644 ${LFS}/etc/shells
 
+# This file contains a list of users (1 per line) who are allowed to shutdown
+# the computer. This doesn't mean that these users can invoke the shutdown
+# (or reboot or halt) command(s). Instead, it means that an authorized user
+# can shut down the computer by pressing ctrl+alt+del.
 echo "Creating /etc/shutdown.allow"
 echo "${REGUSER}" > ${LFS}/etc/shutdown.allow
 
 # Hostname
-echo "${MACHINE_NAME}.${DOMAIN}" > ${LFS}/etc/hostname
+echo "${MACHINE_NAME}" > ${LFS}/etc/hostname
 chmod 644 ${LFS}/etc/hostname
 
 echo "127.0.0.1 localhost ${MACHINE_NAME}" > ${LFS}/etc/hosts