Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.27 KB | None | 0 0
  1. cat > /etc/profile << "EOF"
  2. # Begin /etc/profile
  3. # Written for Beyond Linux From Scratch
  4. # by James Robertson <jameswrobertson@earthlink.net>
  5. # modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
  6.  
  7. # System wide environment variables and startup programs.
  8.  
  9. # System wide aliases and functions should go in /etc/bashrc. Personal
  10. # environment variables and startup programs should go into
  11. # ~/.bash_profile. Personal aliases and functions should go into
  12. # ~/.bashrc.
  13.  
  14. # Functions to help us manage paths. Second argument is the name of the
  15. # path variable to be modified (default: PATH)
  16. pathremove () {
  17. local IFS=':'
  18. local NEWPATH
  19. local DIR
  20. local PATHVARIABLE=${2:-PATH}
  21. for DIR in ${!PATHVARIABLE} ; do
  22. if [ "$DIR" != "$1" ] ; then
  23. NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
  24. fi
  25. done
  26. export $PATHVARIABLE="$NEWPATH"
  27. }
  28.  
  29. pathprepend () {
  30. pathremove $1 $2
  31. local PATHVARIABLE=${2:-PATH}
  32. export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
  33. }
  34.  
  35. pathappend () {
  36. pathremove $1 $2
  37. local PATHVARIABLE=${2:-PATH}
  38. export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
  39. }
  40.  
  41. export -f pathremove pathprepend pathappend
  42.  
  43. # Set the initial path
  44. export PATH=/bin:/usr/bin
  45.  
  46. if [ $EUID -eq 0 ] ; then
  47. pathappend /sbin:/usr/sbin
  48. unset HISTFILE
  49. fi
  50.  
  51. # Setup some environment variables.
  52. export HISTSIZE=1000
  53. export HISTIGNORE="&:[bf]g:exit"
  54.  
  55. # Set some defaults for graphical systems
  56. export XDG_DATA_DIRS=/usr/share/
  57. export XDG_CONFIG_DIRS=/etc/xdg/
  58. export XDG_RUNTIME_DIR=/tmp/xdg-$USER
  59.  
  60. # Setup a red prompt for root and a green one for users.
  61. NORMAL="\[\e[0m\]"
  62. RED="\[\e[1;31m\]"
  63. GREEN="\[\e[1;32m\]"
  64. if [[ $EUID == 0 ]] ; then
  65. PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
  66. else
  67. PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
  68. fi
  69.  
  70. for script in /etc/profile.d/*.sh ; do
  71. if [ -r $script ] ; then
  72. . $script
  73. fi
  74. done
  75.  
  76. unset script RED GREEN NORMAL
  77.  
  78. # End /etc/profile
  79. EOF
  80. install --directory --mode=0755 --owner=root --group=root /etc/profile.d
  81. cat > /etc/profile.d/dircolors.sh << "EOF"
  82. # Setup for /bin/ls and /bin/grep to support color, the alias is in /etc/bashrc.
  83. if [ -f "/etc/dircolors" ] ; then
  84. eval $(dircolors -b /etc/dircolors)
  85. fi
  86.  
  87. if [ -f "$HOME/.dircolors" ] ; then
  88. eval $(dircolors -b $HOME/.dircolors)
  89. fi
  90.  
  91. alias ls='ls --color=auto'
  92. alias grep='grep --color=auto'
  93. EOF
  94. cat > /etc/profile.d/extrapaths.sh << "EOF"
  95. if [ -d /usr/local/lib/pkgconfig ] ; then
  96. pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
  97. fi
  98. if [ -d /usr/local/bin ]; then
  99. pathprepend /usr/local/bin
  100. fi
  101. if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
  102. pathprepend /usr/local/sbin
  103. fi
  104.  
  105. # Set some defaults before other applications add to these paths.
  106. pathappend /usr/share/man MANPATH
  107. pathappend /usr/share/info INFOPATH
  108. EOF
  109. cat > /etc/profile.d/extrapaths.sh << "EOF"
  110. if [ -d /usr/local/lib/pkgconfig ] ; then
  111. pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
  112. fi
  113. if [ -d /usr/local/bin ]; then
  114. pathprepend /usr/local/bin
  115. fi
  116. if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
  117. pathprepend /usr/local/sbin
  118. fi
  119.  
  120. # Set some defaults before other applications add to these paths.
  121. pathappend /usr/share/man MANPATH
  122. pathappend /usr/share/info INFOPATH
  123. EOF
  124. cat > /etc/bashrc << "EOF"
  125. # Begin /etc/bashrc
  126. # Written for Beyond Linux From Scratch
  127. # by James Robertson <jameswrobertson@earthlink.net>
  128. # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
  129.  
  130. # System wide aliases and functions.
  131.  
  132. # System wide environment variables and startup programs should go into
  133. # /etc/profile. Personal environment variables and startup programs
  134. # should go into ~/.bash_profile. Personal aliases and functions should
  135. # go into ~/.bashrc
  136.  
  137. # Provides colored /bin/ls and /bin/grep commands. Used in conjunction
  138. # with code in /etc/profile.
  139.  
  140. alias ls='ls --color=auto'
  141. alias grep='grep --color=auto'
  142.  
  143. # Provides prompt for non-login shells, specifically shells started
  144. # in the X environment. [Review the LFS archive thread titled
  145. # PS1 Environment Variable for a great case study behind this script
  146. # addendum.]
  147.  
  148. NORMAL="\[\e[0m\]"
  149. RED="\[\e[1;31m\]"
  150. GREEN="\[\e[1;32m\]"
  151. if [[ $EUID == 0 ]] ; then
  152. PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
  153. else
  154. PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
  155. fi
  156.  
  157. unset RED GREEN NORMAL
  158.  
  159. # End /etc/bashrc
  160. EOF
  161. cat > ~/.bash_profile << "EOF"
  162. # Begin ~/.bash_profile
  163. # Written for Beyond Linux From Scratch
  164. # by James Robertson <jameswrobertson@earthlink.net>
  165. # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
  166.  
  167. # Personal environment variables and startup programs.
  168.  
  169. # Personal aliases and functions should go in ~/.bashrc. System wide
  170. # environment variables and startup programs are in /etc/profile.
  171. # System wide aliases and functions are in /etc/bashrc.
  172.  
  173. if [ -f "$HOME/.bashrc" ] ; then
  174. source $HOME/.bashrc
  175. fi
  176.  
  177. if [ -d "$HOME/bin" ] ; then
  178. pathprepend $HOME/bin
  179. fi
  180.  
  181. # Having . in the PATH is dangerous
  182. #if [ $EUID -gt 99 ]; then
  183. # pathappend .
  184. #fi
  185.  
  186. # End ~/.bash_profile
  187. EOF
  188. cat > ~/.profile << "EOF"
  189. # Begin ~/.profile
  190. # Personal environment variables and startup programs.
  191.  
  192. if [ -d "$HOME/bin" ] ; then
  193. pathprepend $HOME/bin
  194. fi
  195.  
  196. # Set up user specific i18n variables
  197. #export LANG=<ll>_<CC>.<charmap><@modifiers>
  198.  
  199. # End ~/.profile
  200. EOF
  201. cat > ~/.bashrc << "EOF"
  202. # Begin ~/.bashrc
  203. # Written for Beyond Linux From Scratch
  204. # by James Robertson <jameswrobertson@earthlink.net>
  205.  
  206. # Personal aliases and functions.
  207.  
  208. # Personal environment variables and startup programs should go in
  209. # ~/.bash_profile. System wide environment variables and startup
  210. # programs are in /etc/profile. System wide aliases and functions are
  211. # in /etc/bashrc.
  212.  
  213. if [ -f "/etc/bashrc" ] ; then
  214. source /etc/bashrc
  215. fi
  216.  
  217. # Set up user specific i18n variables
  218. #export LANG=<ll>_<CC>.<charmap><@modifiers>
  219.  
  220. # End ~/.bashrc
  221. EOF
  222. cat > ~/.bash_logout << "EOF"
  223. # Begin ~/.bash_logout
  224. # Written for Beyond Linux From Scratch
  225. # by James Robertson <jameswrobertson@earthlink.net>
  226.  
  227. # Personal items to perform on logout.
  228.  
  229. # End ~/.bash_logout
  230. EOF
  231. dircolors -p > /etc/dircolors
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement