source: scripts/native-scripts/post-lfs-configuration.sh@ 3d3002d

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 3d3002d was 617118d, checked in by Jim Gifford <clfs@…>, 19 years ago

r561@server (orig r559): root | 2005-06-05 02:38:49 -0700
Fixed Directory Structure

  • Property mode set to 100755
File size: 9.9 KB
RevLine 
[617118d]1#!/bin/bash
2
3# post cross-lfs configuration
4# ----------------------------
5# $LastChangedBy$
6# $LastChangedDate$
7# $LastChangedRevision$
8# $HeadURL$
9#
10
11# TODO: Add support somehow for multi-arch systems...
12# May just copy the multi-arch funcs script onto the host and use
13# that...
14
15if [ ! -d /etc/default ]; then mkdir /etc/default ; fi
16
17# OK, these defaults for useradd are probably peculiar to the script authors
18# preferences (homedirs are generally nfs mounted)
19if [ "${HOME_NFS_MOUNTED}" = "Y" ]; then
20 HOMEDIR=/home/$( uname -n )
21else
22 HOMEDIR=/home
23fi
24
25if [ ! -d ${HOMEDIR} ]; then mkdir -p ${HOMEDIR} ; fi
26
27cat > /etc/default/useradd << EOF
28# Begin /etc/default/useradd
29
30GROUP=100
31HOME=${HOMEDIR}
32INACTIVE=-1
33EXPIRE=
34SHELL=/bin/bash
35SKEL=/etc/skel
36
37# End /etc/default/useradd
38EOF
39
40if [ "${MULTIARCH}" = "Y" ]; then
41multiarch_additions='
42# The following from cross-lfs multiarch-funcs script
43
44# From set_libdirname function...
45
46# TODO: this will barf on mips if setting 64bit libs to go to */lib
47# but will work if setting
48if [ -z "${BUILDENV}" ]; then
49 BUILDENV=${DEFAULTENV}
50 export BUILDENV
51fi
52if [ ! "${BUILDENV}" = "${LIBDIRENV}" ]; then
53 case ${BUILDENV} in
54 32 | o32 | n32 ) libdirname=lib32 ;;
55 64 | o64 ) libdirname=lib64 ;;
56 * ) echo "unknown buildenv ${BUILDENV}"; return 1
57 esac
58 LOG=`echo ${LOG} | sed "s@\.log@-${BUILDENV}&@"`
59else
60 libdirname=lib
61fi
62
63# Adjust PKG_CONFIG_PATH
64PKG_CONFIG_PATH=`echo "${PKG_CONFIG_PATH}" | \
65 sed -e "s@lib[36][124]@lib@g" -e "s@lib@${libdirname}@g" `
66
67# Adjust GNOME_LIBCONF_PATH
68GNOME_LIBCONF_PATH=`echo "${GNOME_LIBCONF_PATH}" | \
69 sed -e "s@lib[36][124]@lib@g" -e "s@lib@${libdirname}@g" `
70'
71fi
72
73cat > /etc/profile << "EOF"
74# Begin /etc/profile
75# Written for Beyond Linux From Scratch
76# by James Robertson <jameswrobertson@earthlink.net>
77# modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
78
79# System wide environment variables and startup programs.
80
81# System wide aliases and functions should go in /etc/bashrc. Personal
82# environment variables and startup programs should go into
83# ~/.bash_profile. Personal aliases and functions should go into
84# ~/.bashrc.
85
86# Functions to help us manage paths. Second argument is the name of the
87# path variable to be modified (default: PATH)
88pathremove () {
89 local IFS=':'
90 local NEWPATH
91 local DIR
92 local PATHVARIABLE=${2:-PATH}
93 for DIR in ${!PATHVARIABLE} ; do
94 if [ "${DIR}" != "${1}" ] ; then
95 NEWPATH=${NEWPATH:+$NEWPATH:}${DIR}
96 fi
97 done
98 export ${PATHVARIABLE}="${NEWPATH}"
99}
100
101pathprepend () {
102 pathremove ${1} ${2}
103 local PATHVARIABLE=${2:-PATH}
104 export ${PATHVARIABLE}="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
105}
106
107pathappend () {
108 pathremove ${1} ${2}
109 local PATHVARIABLE=${2:-PATH}
110 export ${PATHVARIABLE}="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
111}
112
113
114# Set the initial path
115export PATH=/bin:/usr/bin
116
117if [ ${EUID} -eq 0 ] ; then
118 pathappend /sbin:/usr/sbin
119 unset HISTFILE
120fi
121
122# Setup some environment variables.
123export HISTSIZE=1000
124export HISTIGNORE="&:[bf]g:exit"
125#export PS1="[\u@\h \w]\\$ "
126export PS1='\u@\h:\w\$ '
127
128for script in /etc/profile.d/*.sh ; do
129 if [ -r ${script} ] ; then
130 . ${script}
131 fi
132done
133
134# Now to clean up
135unset pathremove pathprepend pathappend
136
137EOF
138
139if [ "${MULTIARCH}" = "Y" ]; then
140 echo "${multiarch_additions}" >> /etc/profile
141fi
142echo "# End /etc/profile" >> /etc/profile
143
144install --directory --mode=0755 --owner=root --group=root /etc/profile.d
145
146cat > /etc/profile.d/dircolors.sh << "EOF"
147# Setup for /bin/ls to support color, the alias is in /etc/bashrc.
148if [ -f "/etc/dircolors" ] ; then
149 eval $(dircolors -b /etc/dircolors)
150
151 if [ -f "${HOME}/.dircolors" ] ; then
152 eval $(dircolors -b ${HOME}/.dircolors)
153 fi
154fi
155alias ls='ls --color=auto'
156EOF
157
158# This script adds several useful paths to the PATH and PKG_CONFIG_PATH
159# environment variables.
160
161cat > /etc/profile.d/extrapaths.sh << "EOF"
162if [ -d /usr/local/lib/pkgconfig ] ; then
163 pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
164fi
165if [ -d /usr/local/bin ]; then
166 pathprepend /usr/local/bin
167fi
168if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
169 pathprepend /usr/local/sbin
170fi
171for directory in $(find /opt/*/lib/pkgconfig -type d 2>/dev/null); do
172 pathappend ${directory} PKG_CONFIG_PATH
173done
174for directory in $(find /opt/*/bin -type d 2>/dev/null); do
175 pathappend ${directory}
176done
177if [ -d ~/bin ]; then
178 pathprepend ~/bin
179fi
180#if [ $EUID -gt 99 ]; then
181# pathappend .
182#fi
183EOF
184
185# This script sets up the default inputrc configuration file.
186# If the user does not have individual settings, it uses the global file.
187
188cat > /etc/profile.d/readline.sh << "EOF"
189# Setup the INPUTRC environment variable.
190if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
191 INPUTRC=/etc/inputrc
192fi
193export INPUTRC
194EOF
195
196
197# Some applications need a specific TERM setting to support color.
198
199cat > /etc/profile.d/tinker-term.sh << "EOF"
200# This will tinker with the value of TERM in order to convince certain
201# apps that we can, indeed, display color in their window.
202
203if [ -n "$COLORTERM" ]; then
204 export TERM=xterm-color
205fi
206
207if [ "$TERM" = "xterm" ]; then
208 export TERM=xterm-color
209fi
210EOF
211
212# Setting the umask value is important for security.
213# Here the default group write permissions are turned off for system users
214# and when the user name and group name are not the same.
215
216cat > /etc/profile.d/umask.sh << "EOF"
217# By default we want the umask to get set.
218if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
219 umask 002
220else
221 umask 022
222fi
223EOF
224
225
226# If X is installed, the PATH and PKG_CONFIG_PATH variables are also updated.
227
228cat > /etc/profile.d/X.sh << "EOF"
229if [ -x /usr/X11R6/bin/X ]; then
230 pathappend /usr/X11R6/bin
231fi
232if [ -d /usr/X11R6/lib/pkgconfig ] ; then
233 pathappend /usr/X11R6/lib/pkgconfig PKG_CONFIG_PATH
234fi
235EOF
236
237
238# This script shows an example of a different way of setting the prompt.
239# The normal variable, PS1, is supplemented by PROMPT_COMMAND. If set,
240# the value of PROMPT_COMMAND is executed as a command prior to issuing
241# each primary prompt.
242
243cat > /etc/profile.d/xterm-titlebars.sh << "EOF"
244# The substring match ensures this works for "xterm" and "xterm-xfree86".
245if [ "${TERM:0:5}" = "xterm" ]; then
246 PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME} : ${PWD}\007"'
247 export PROMPT_COMMAND
248fi
249EOF
250
251if [ "${MULTIARCH}" = "Y" ]; then
252cat > /etc/profile.d/multiarch-defaults.sh << EOF
253# Set default ABI and which ABI goes into */lib
254export DEFAULTENV="${DEFAULTENV}"
255export LIBDIRENV="${LIBDIRENV}"
256
257# Force each bash script invocation to use /etc/bashrc .
258export BASH_ENV="/etc/bashrc"
259EOF
260fi
261
262# Here is a base /etc/bashrc.
263# Comments in the file should explain everything you need.
264
265cat > /etc/bashrc << "EOF"
266# Begin /etc/bashrc
267# Written for Beyond Linux From Scratch
268# by James Robertson <jameswrobertson@earthlink.net>
269# updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
270
271# Make sure that the terminal is set up properly for each shell
272
273if [ -f /etc/profile.d/tinker-term.sh ]; then
274 source /etc/profile.d/tinker-term.sh
275fi
276
277if [ -f /etc/profile.d/xterm-titlebars.sh ]; then
278 source /etc/profile.d/xterm-titlebars.sh
279fi
280
281# System wide aliases and functions.
282
283# System wide environment variables and startup programs should go into
284# /etc/profile. Personal environment variables and startup programs
285# should go into ~/.bash_profile. Personal aliases and functions should
286# go into ~/.bashrc
287
288# Provides a colored /bin/ls command. Used in conjunction with code in
289# /etc/profile.
290
291alias ls='ls --color=auto'
292
293# Provides prompt for non-login shells, specifically shells started
294# in the X environment. [Review the LFS archive thread titled
295# PS1 Environment Variable for a great case study behind this script
296# addendum.]
297
298#export PS1="[\u@\h \w]\\$ "
299export PS1='\u@\h:\w\$ '
300
301EOF
302
303if [ "${MULTIARCH}" = "Y" ]; then
304 echo "${multiarch_additions}" >> /etc/bashrc
305fi
306echo "# End /etc/bashrc" >> /etc/bashrc
307
308if [ ! -d /etc/skel ]; then mkdir -p /etc/skel ; fi
309
310# .bash_profile
311
312cat > /etc/skel/.bash_profile << "EOF"
313# Begin ~/.bash_profile
314# Written for Beyond Linux From Scratch
315# by James Robertson <jameswrobertson@earthlink.net>
316# updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
317
318# Personal environment variables and startup programs.
319
320# Personal aliases and functions should go in ~/.bashrc. System wide
321# environment variables and startup programs are in /etc/profile.
322# System wide aliases and functions are in /etc/bashrc.
323
324append () {
325 # First remove the directory
326 local IFS=':'
327 local NEWPATH
328 for DIR in ${PATH}; do
329 if [ "${DIR}" != "${1}" ]; then
330 NEWPATH="${NEWPATH:+${NEWPATH}:}${DIR}"
331 fi
332 done
333
334 # Then append the directory
335 export PATH="${NEWPATH}:${1}"
336}
337
338if [ -f "${HOME}/.bashrc" ] ; then
339 source ${HOME}/.bashrc
340fi
341
342if [ -d "${HOME}/bin" ] ; then
343 append ${HOME}/bin
344fi
345
346unset append
347
348# End ~/.bash_profile
349EOF
350
351# .bashrc
352
353cat > /etc/skel/.bashrc << "EOF"
354# Begin ~/.bashrc
355# Written for Beyond Linux From Scratch
356# by James Robertson <jameswrobertson@earthlink.net>
357
358# Personal aliases and functions.
359
360# Personal environment variables and startup programs should go in
361# ~/.bash_profile. System wide environment variables and startup
362# programs are in /etc/profile. System wide aliases and functions are
363# in /etc/bashrc.
364
365if [ -f "/etc/bashrc" ] ; then
366 source /etc/bashrc
367fi
368
369# End ~/.bashrc
370EOF
371
372# .bash_logout
373
374cat > /etc/skel/.bash_logout << "EOF"
375# Begin ~/.bash_logout
376# Written for Beyond Linux From Scratch
377# by James Robertson <jameswrobertson@earthlink.net>
378
379# Personal items to perform on logout.
380
381# End ~/.bash_logout
382EOF
383
384# .vimrc
385
386cat > /etc/skel/.vimrc << "EOF"
387" Begin .vimrc
388
389set nocompatible
390set bs=2
391" set columns=80
392set background=dark " use colours which look good on a dark background
393" set wrapmargin=8
394set ruler
395
396syntax on " syntax highlighting
397set hlsearch " highlight last used search pattern
398
399" End .vimrc
400EOF
401
402cp /etc/skel/{.bash_profile,.bashrc,.vimrc} /root
403
404dircolors -p > /etc/dircolors
405
406cat > /etc/shells << "EOF"
407# Begin /etc/shells
408
409/bin/sh
410/bin/bash
411
412# End /etc/shells
413EOF
414
415
Note: See TracBrowser for help on using the repository browser.