Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.19 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/bash_completion.sh << "EOF"
  82. # Begin /etc/profile.d/bash_completion.sh
  83. # Import bash completion scripts
  84.  
  85. for script in /etc/bash_completion.d/*.sh ; do
  86. if [ -r $script ] ; then
  87. . $script
  88. fi
  89. done
  90. # End /etc/profile.d/bash_completion.sh
  91. EOF
  92. install --directory --mode=0755 --owner=root --group=root /etc/bash_completion.d
  93. cat > /etc/profile.d/dircolors.sh << "EOF"
  94. # Setup for /bin/ls and /bin/grep to support color, the alias is in /etc/bashrc.
  95. if [ -f "/etc/dircolors" ] ; then
  96. eval $(dircolors -b /etc/dircolors)
  97. fi
  98.  
  99. if [ -f "$HOME/.dircolors" ] ; then
  100. eval $(dircolors -b $HOME/.dircolors)
  101. fi
  102.  
  103. alias ls='ls --color=auto'
  104. alias grep='grep --color=auto'
  105. EOF
  106. cat > /etc/profile.d/extrapaths.sh << "EOF"
  107. if [ -d /usr/local/lib/pkgconfig ] ; then
  108. pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
  109. fi
  110. if [ -d /usr/local/bin ]; then
  111. pathprepend /usr/local/bin
  112. fi
  113. if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
  114. pathprepend /usr/local/sbin
  115. fi
  116.  
  117. # Set some defaults before other applications add to these paths.
  118. pathappend /usr/share/man MANPATH
  119. pathappend /usr/share/info INFOPATH
  120. EOF
  121. cat > /etc/bashrc << "EOF"
  122. # Begin /etc/bashrc
  123. # Written for Beyond Linux From Scratch
  124. # by James Robertson <jameswrobertson@earthlink.net>
  125. # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
  126.  
  127. # System wide aliases and functions.
  128.  
  129. # System wide environment variables and startup programs should go into
  130. # /etc/profile. Personal environment variables and startup programs
  131. # should go into ~/.bash_profile. Personal aliases and functions should
  132. # go into ~/.bashrc
  133.  
  134. # Provides colored /bin/ls and /bin/grep commands. Used in conjunction
  135. # with code in /etc/profile.
  136.  
  137. alias ls='ls --color=auto'
  138. alias grep='grep --color=auto'
  139.  
  140. # Provides prompt for non-login shells, specifically shells started
  141. # in the X environment. [Review the LFS archive thread titled
  142. # PS1 Environment Variable for a great case study behind this script
  143. # addendum.]
  144.  
  145. NORMAL="\[\e[0m\]"
  146. RED="\[\e[1;31m\]"
  147. GREEN="\[\e[1;32m\]"
  148. if [[ $EUID == 0 ]] ; then
  149. PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
  150. else
  151. PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
  152. fi
  153.  
  154. unset RED GREEN NORMAL
  155.  
  156. # End /etc/bashrc
  157. EOF
  158. cat > ~/.bash_profile << "EOF"
  159. # Begin ~/.bash_profile
  160. # Written for Beyond Linux From Scratch
  161. # by James Robertson <jameswrobertson@earthlink.net>
  162. # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
  163.  
  164. # Personal environment variables and startup programs.
  165.  
  166. # Personal aliases and functions should go in ~/.bashrc. System wide
  167. # environment variables and startup programs are in /etc/profile.
  168. # System wide aliases and functions are in /etc/bashrc.
  169.  
  170. if [ -f "$HOME/.bashrc" ] ; then
  171. source $HOME/.bashrc
  172. fi
  173.  
  174. if [ -d "$HOME/bin" ] ; then
  175. pathprepend $HOME/bin
  176. fi
  177.  
  178. # Having . in the PATH is dangerous
  179. #if [ $EUID -gt 99 ]; then
  180. # pathappend .
  181. #fi
  182.  
  183. # End ~/.bash_profile
  184. EOF
  185. cat > ~/.profile << "EOF"
  186. # Begin ~/.profile
  187. # Personal environment variables and startup programs.
  188.  
  189. if [ -d "$HOME/bin" ] ; then
  190. pathprepend $HOME/bin
  191. fi
  192.  
  193. # Set up user specific i18n variables
  194. #export LANG=<ll>_<CC>.<charmap><@modifiers>
  195.  
  196. # End ~/.profile
  197. EOF
  198. cat > ~/.bashrc << "EOF"
  199. # Begin ~/.bashrc
  200. # Written for Beyond Linux From Scratch
  201. # by James Robertson <jameswrobertson@earthlink.net>
  202.  
  203. # Personal aliases and functions.
  204.  
  205. # Personal environment variables and startup programs should go in
  206. # ~/.bash_profile. System wide environment variables and startup
  207. # programs are in /etc/profile. System wide aliases and functions are
  208. # in /etc/bashrc.
  209.  
  210. if [ -f "/etc/bashrc" ] ; then
  211. source /etc/bashrc
  212. fi
  213.  
  214. # Set up user specific i18n variables
  215. #export LANG=<ll>_<CC>.<charmap><@modifiers>
  216.  
  217. # End ~/.bashrc
  218. EOF
  219. cat > ~/.bash_logout << "EOF"
  220. # Begin ~/.bash_logout
  221. # Written for Beyond Linux From Scratch
  222. # by James Robertson <jameswrobertson@earthlink.net>
  223.  
  224. # Personal items to perform on logout.
  225.  
  226. # End ~/.bash_logout
  227. EOF
  228. dircolors -p > /etc/dircolors
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement