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 |
|
---|
15 | if [ ! -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)
|
---|
19 | if [ "${HOME_NFS_MOUNTED}" = "Y" ]; then
|
---|
20 | HOMEDIR=/home/$( uname -n )
|
---|
21 | else
|
---|
22 | HOMEDIR=/home
|
---|
23 | fi
|
---|
24 |
|
---|
25 | if [ ! -d ${HOMEDIR} ]; then mkdir -p ${HOMEDIR} ; fi
|
---|
26 |
|
---|
27 | cat > /etc/default/useradd << EOF
|
---|
28 | # Begin /etc/default/useradd
|
---|
29 |
|
---|
30 | GROUP=100
|
---|
31 | HOME=${HOMEDIR}
|
---|
32 | INACTIVE=-1
|
---|
33 | EXPIRE=
|
---|
34 | SHELL=/bin/bash
|
---|
35 | SKEL=/etc/skel
|
---|
36 |
|
---|
37 | # End /etc/default/useradd
|
---|
38 | EOF
|
---|
39 |
|
---|
40 | if [ "${MULTIARCH}" = "Y" ]; then
|
---|
41 | multiarch_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
|
---|
48 | if [ -z "${BUILDENV}" ]; then
|
---|
49 | BUILDENV=${DEFAULTENV}
|
---|
50 | export BUILDENV
|
---|
51 | fi
|
---|
52 | if [ ! "${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}&@"`
|
---|
59 | else
|
---|
60 | libdirname=lib
|
---|
61 | fi
|
---|
62 |
|
---|
63 | # Adjust PKG_CONFIG_PATH
|
---|
64 | PKG_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
|
---|
68 | GNOME_LIBCONF_PATH=`echo "${GNOME_LIBCONF_PATH}" | \
|
---|
69 | sed -e "s@lib[36][124]@lib@g" -e "s@lib@${libdirname}@g" `
|
---|
70 | '
|
---|
71 | fi
|
---|
72 |
|
---|
73 | cat > /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)
|
---|
88 | pathremove () {
|
---|
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 |
|
---|
101 | pathprepend () {
|
---|
102 | pathremove ${1} ${2}
|
---|
103 | local PATHVARIABLE=${2:-PATH}
|
---|
104 | export ${PATHVARIABLE}="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
|
---|
105 | }
|
---|
106 |
|
---|
107 | pathappend () {
|
---|
108 | pathremove ${1} ${2}
|
---|
109 | local PATHVARIABLE=${2:-PATH}
|
---|
110 | export ${PATHVARIABLE}="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | # Set the initial path
|
---|
115 | export PATH=/bin:/usr/bin
|
---|
116 |
|
---|
117 | if [ ${EUID} -eq 0 ] ; then
|
---|
118 | pathappend /sbin:/usr/sbin
|
---|
119 | unset HISTFILE
|
---|
120 | fi
|
---|
121 |
|
---|
122 | # Setup some environment variables.
|
---|
123 | export HISTSIZE=1000
|
---|
124 | export HISTIGNORE="&:[bf]g:exit"
|
---|
125 | #export PS1="[\u@\h \w]\\$ "
|
---|
126 | export PS1='\u@\h:\w\$ '
|
---|
127 |
|
---|
128 | for script in /etc/profile.d/*.sh ; do
|
---|
129 | if [ -r ${script} ] ; then
|
---|
130 | . ${script}
|
---|
131 | fi
|
---|
132 | done
|
---|
133 |
|
---|
134 | # Now to clean up
|
---|
135 | unset pathremove pathprepend pathappend
|
---|
136 |
|
---|
137 | EOF
|
---|
138 |
|
---|
139 | if [ "${MULTIARCH}" = "Y" ]; then
|
---|
140 | echo "${multiarch_additions}" >> /etc/profile
|
---|
141 | fi
|
---|
142 | echo "# End /etc/profile" >> /etc/profile
|
---|
143 |
|
---|
144 | install --directory --mode=0755 --owner=root --group=root /etc/profile.d
|
---|
145 |
|
---|
146 | cat > /etc/profile.d/dircolors.sh << "EOF"
|
---|
147 | # Setup for /bin/ls to support color, the alias is in /etc/bashrc.
|
---|
148 | if [ -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
|
---|
154 | fi
|
---|
155 | alias ls='ls --color=auto'
|
---|
156 | EOF
|
---|
157 |
|
---|
158 | # This script adds several useful paths to the PATH and PKG_CONFIG_PATH
|
---|
159 | # environment variables.
|
---|
160 |
|
---|
161 | cat > /etc/profile.d/extrapaths.sh << "EOF"
|
---|
162 | if [ -d /usr/local/lib/pkgconfig ] ; then
|
---|
163 | pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
|
---|
164 | fi
|
---|
165 | if [ -d /usr/local/bin ]; then
|
---|
166 | pathprepend /usr/local/bin
|
---|
167 | fi
|
---|
168 | if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
|
---|
169 | pathprepend /usr/local/sbin
|
---|
170 | fi
|
---|
171 | for directory in $(find /opt/*/lib/pkgconfig -type d 2>/dev/null); do
|
---|
172 | pathappend ${directory} PKG_CONFIG_PATH
|
---|
173 | done
|
---|
174 | for directory in $(find /opt/*/bin -type d 2>/dev/null); do
|
---|
175 | pathappend ${directory}
|
---|
176 | done
|
---|
177 | if [ -d ~/bin ]; then
|
---|
178 | pathprepend ~/bin
|
---|
179 | fi
|
---|
180 | #if [ $EUID -gt 99 ]; then
|
---|
181 | # pathappend .
|
---|
182 | #fi
|
---|
183 | EOF
|
---|
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 |
|
---|
188 | cat > /etc/profile.d/readline.sh << "EOF"
|
---|
189 | # Setup the INPUTRC environment variable.
|
---|
190 | if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
|
---|
191 | INPUTRC=/etc/inputrc
|
---|
192 | fi
|
---|
193 | export INPUTRC
|
---|
194 | EOF
|
---|
195 |
|
---|
196 |
|
---|
197 | # Some applications need a specific TERM setting to support color.
|
---|
198 |
|
---|
199 | cat > /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 |
|
---|
203 | if [ -n "$COLORTERM" ]; then
|
---|
204 | export TERM=xterm-color
|
---|
205 | fi
|
---|
206 |
|
---|
207 | if [ "$TERM" = "xterm" ]; then
|
---|
208 | export TERM=xterm-color
|
---|
209 | fi
|
---|
210 | EOF
|
---|
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 |
|
---|
216 | cat > /etc/profile.d/umask.sh << "EOF"
|
---|
217 | # By default we want the umask to get set.
|
---|
218 | if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
|
---|
219 | umask 002
|
---|
220 | else
|
---|
221 | umask 022
|
---|
222 | fi
|
---|
223 | EOF
|
---|
224 |
|
---|
225 |
|
---|
226 | # If X is installed, the PATH and PKG_CONFIG_PATH variables are also updated.
|
---|
227 |
|
---|
228 | cat > /etc/profile.d/X.sh << "EOF"
|
---|
229 | if [ -x /usr/X11R6/bin/X ]; then
|
---|
230 | pathappend /usr/X11R6/bin
|
---|
231 | fi
|
---|
232 | if [ -d /usr/X11R6/lib/pkgconfig ] ; then
|
---|
233 | pathappend /usr/X11R6/lib/pkgconfig PKG_CONFIG_PATH
|
---|
234 | fi
|
---|
235 | EOF
|
---|
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 |
|
---|
243 | cat > /etc/profile.d/xterm-titlebars.sh << "EOF"
|
---|
244 | # The substring match ensures this works for "xterm" and "xterm-xfree86".
|
---|
245 | if [ "${TERM:0:5}" = "xterm" ]; then
|
---|
246 | PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME} : ${PWD}\007"'
|
---|
247 | export PROMPT_COMMAND
|
---|
248 | fi
|
---|
249 | EOF
|
---|
250 |
|
---|
251 | if [ "${MULTIARCH}" = "Y" ]; then
|
---|
252 | cat > /etc/profile.d/multiarch-defaults.sh << EOF
|
---|
253 | # Set default ABI and which ABI goes into */lib
|
---|
254 | export DEFAULTENV="${DEFAULTENV}"
|
---|
255 | export LIBDIRENV="${LIBDIRENV}"
|
---|
256 |
|
---|
257 | # Force each bash script invocation to use /etc/bashrc .
|
---|
258 | export BASH_ENV="/etc/bashrc"
|
---|
259 | EOF
|
---|
260 | fi
|
---|
261 |
|
---|
262 | # Here is a base /etc/bashrc.
|
---|
263 | # Comments in the file should explain everything you need.
|
---|
264 |
|
---|
265 | cat > /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 |
|
---|
273 | if [ -f /etc/profile.d/tinker-term.sh ]; then
|
---|
274 | source /etc/profile.d/tinker-term.sh
|
---|
275 | fi
|
---|
276 |
|
---|
277 | if [ -f /etc/profile.d/xterm-titlebars.sh ]; then
|
---|
278 | source /etc/profile.d/xterm-titlebars.sh
|
---|
279 | fi
|
---|
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 |
|
---|
291 | alias 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]\\$ "
|
---|
299 | export PS1='\u@\h:\w\$ '
|
---|
300 |
|
---|
301 | EOF
|
---|
302 |
|
---|
303 | if [ "${MULTIARCH}" = "Y" ]; then
|
---|
304 | echo "${multiarch_additions}" >> /etc/bashrc
|
---|
305 | fi
|
---|
306 | echo "# End /etc/bashrc" >> /etc/bashrc
|
---|
307 |
|
---|
308 | if [ ! -d /etc/skel ]; then mkdir -p /etc/skel ; fi
|
---|
309 |
|
---|
310 | # .bash_profile
|
---|
311 |
|
---|
312 | cat > /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 |
|
---|
324 | append () {
|
---|
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 |
|
---|
338 | if [ -f "${HOME}/.bashrc" ] ; then
|
---|
339 | source ${HOME}/.bashrc
|
---|
340 | fi
|
---|
341 |
|
---|
342 | if [ -d "${HOME}/bin" ] ; then
|
---|
343 | append ${HOME}/bin
|
---|
344 | fi
|
---|
345 |
|
---|
346 | unset append
|
---|
347 |
|
---|
348 | # End ~/.bash_profile
|
---|
349 | EOF
|
---|
350 |
|
---|
351 | # .bashrc
|
---|
352 |
|
---|
353 | cat > /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 |
|
---|
365 | if [ -f "/etc/bashrc" ] ; then
|
---|
366 | source /etc/bashrc
|
---|
367 | fi
|
---|
368 |
|
---|
369 | # End ~/.bashrc
|
---|
370 | EOF
|
---|
371 |
|
---|
372 | # .bash_logout
|
---|
373 |
|
---|
374 | cat > /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
|
---|
382 | EOF
|
---|
383 |
|
---|
384 | # .vimrc
|
---|
385 |
|
---|
386 | cat > /etc/skel/.vimrc << "EOF"
|
---|
387 | " Begin .vimrc
|
---|
388 |
|
---|
389 | set nocompatible
|
---|
390 | set bs=2
|
---|
391 | " set columns=80
|
---|
392 | set background=dark " use colours which look good on a dark background
|
---|
393 | " set wrapmargin=8
|
---|
394 | set ruler
|
---|
395 |
|
---|
396 | syntax on " syntax highlighting
|
---|
397 | set hlsearch " highlight last used search pattern
|
---|
398 |
|
---|
399 | " End .vimrc
|
---|
400 | EOF
|
---|
401 |
|
---|
402 | cp /etc/skel/{.bash_profile,.bashrc,.vimrc} /root
|
---|
403 |
|
---|
404 | dircolors -p > /etc/dircolors
|
---|
405 |
|
---|
406 | cat > /etc/shells << "EOF"
|
---|
407 | # Begin /etc/shells
|
---|
408 |
|
---|
409 | /bin/sh
|
---|
410 | /bin/bash
|
---|
411 |
|
---|
412 | # End /etc/shells
|
---|
413 | EOF
|
---|
414 |
|
---|
415 |
|
---|