reworked/improved setup files
parent
256186376d
commit
5d2ccc7c4f
|
@ -1,17 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# uncomment these for debugging.
|
# non-interactive shell
|
||||||
# echo ---- sourcing system wide bash.bashrc ---
|
|
||||||
# [ $EUID -eq 0 ] && echo 'Root User' || echo 'Non Root User'
|
|
||||||
# [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
|
|
||||||
# shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'
|
|
||||||
# ([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]) && echo ssh remote user || echo local user
|
|
||||||
# echo ---------------------
|
|
||||||
|
|
||||||
if ([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]); then
|
([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]) && export SSH_SESSION=true
|
||||||
export SSH_SESSION=true
|
[[ $- == *i* ]] && export SHELL_INTERACTIVE=true
|
||||||
source /etc/profile
|
shopt -q login_shell && export SHELL_LOGIN=true
|
||||||
fi
|
[ $EUID -eq 0 ] && export USER_ROOT=true
|
||||||
# global debug on or off via debug_on debug_off aliases
|
|
||||||
# can add this export to any file
|
#uncomment these for debugging.
|
||||||
#export BASH_DEBUG=true
|
# echo ---- sourcing system wide bash.bashrc ---
|
||||||
source $BASH_SHELL_LOAD
|
# [[ $USER_ROOT ]] && echo 'Root User' || echo 'Non Root User'
|
||||||
|
# [[ $SHELL_INTERACTIVE ]] && echo 'Interactive' || echo 'Not interactive'
|
||||||
|
# [[ $SHELL_LOGIN ]] && echo 'Login shell' || echo 'Not login shell'
|
||||||
|
# [[ $SSH_SESSION ]] && echo ssh remote user || echo local user
|
||||||
|
# echo ---------------------
|
||||||
|
|
||||||
|
if ( [[ $SHELL_INTERACTIVE ]] );then
|
||||||
|
source /etc/profile
|
||||||
|
else
|
||||||
|
# Set the initial path
|
||||||
|
export PATH=/bin:/usr/bin:/usr/local/bin
|
||||||
|
# set this for access to any shell sources
|
||||||
|
export BASH_SHELL_BASE=/opt/bash/shell/base
|
||||||
|
# loading module functions
|
||||||
|
source $BASH_SHELL_BASE/module.lib
|
||||||
|
fi
|
|
@ -1,14 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# put no script code directly here.
|
# do not add code here.
|
||||||
# organize all script code in files /etc/profile.d
|
# organize additional profile script code in files /etc/profile.d
|
||||||
|
|
||||||
# uncomment for debugging
|
([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]) && export SSH_SESSION=true
|
||||||
# echo ---- system profile /etc/profile sourced at login ----
|
[[ $- == *i* ]] && export SHELL_INTERACTIVE=true
|
||||||
# [ $EUID -eq 0 ] && echo 'Root User' || echo 'Non Root User'
|
shopt -q login_shell && export SHELL_LOGIN=true
|
||||||
# [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
|
[ $EUID -eq 0 ] && export USER_ROOT=true
|
||||||
# shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'
|
|
||||||
# echo -----------
|
|
||||||
|
#uncomment these for debugging.
|
||||||
|
# echo ---- sourcing system /etc/profile ---
|
||||||
|
# [[ $USER_ROOT ]] && echo 'Root User' || echo 'Non Root User'
|
||||||
|
# [[ $SHELL_INTERACTIVE ]] && echo 'Interactive' || echo 'Not interactive'
|
||||||
|
# [[ $SHELL_LOGIN ]] && echo 'Login shell' || echo 'Not login shell'
|
||||||
|
# [[ $SSH_SESSION ]] && echo ssh remote user || echo local user
|
||||||
|
# echo ---------------------
|
||||||
|
|
||||||
# main /etc/profile loaded for all logins
|
# main /etc/profile loaded for all logins
|
||||||
# more info see http://www.linuxfromscratch.org/blfs/view/svn/postlfs/profile.html
|
# more info see http://www.linuxfromscratch.org/blfs/view/svn/postlfs/profile.html
|
||||||
|
@ -20,13 +27,13 @@ export BASH_SHELL_BASE=THISWILLCHANGEDBYDEPLOYSCRIPT
|
||||||
# now bootstrap by souring the shell repo envinroment
|
# now bootstrap by souring the shell repo envinroment
|
||||||
source $BASH_SHELL_BASE/shell.env
|
source $BASH_SHELL_BASE/shell.env
|
||||||
# uncomment to NOT load the BASH SHELL Repos for interactive login shell
|
# uncomment to NOT load the BASH SHELL Repos for interactive login shell
|
||||||
# NO_LOGIN_BASHRC=true
|
# NO_BASH_SHELL=true
|
||||||
if [[ $- == *i* ]]; then # interactive?
|
if [[ $SHELL_INTERACTIVE ]]; then
|
||||||
[[ ! $SSH_SESSION ]] && echo interactive login shell
|
if [[ ! $NO_BASH_SHELL ]]; then
|
||||||
if [[ ! $NO_LOGIN_BASHRC ]]; then
|
|
||||||
# echo interactive shell loading $BASH_SHELL_LOAD
|
# echo interactive shell loading $BASH_SHELL_LOAD
|
||||||
source "$BASH_SHELL_LOAD"
|
source "$BASH_SHELL_LOAD"
|
||||||
else
|
else
|
||||||
|
# just set a simple prompt instead
|
||||||
NORMAL="\[\e[0m\]"
|
NORMAL="\[\e[0m\]"
|
||||||
RED="\[\e[1;31m\]"
|
RED="\[\e[1;31m\]"
|
||||||
GREEN="\[\e[1;32m\]"
|
GREEN="\[\e[1;32m\]"
|
||||||
|
@ -38,6 +45,7 @@ if [[ $- == *i* ]]; then # interactive?
|
||||||
unset RED GREEN NORMAL
|
unset RED GREEN NORMAL
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
# this is non-interactive login (e.g. at user machine login)
|
||||||
if [[ $EUID -ne 0 ]] && [[ ! $SSH_SESSION ]]; then
|
if [[ $EUID -ne 0 ]] && [[ ! $SSH_SESSION ]]; then
|
||||||
export LOGIN_LOG=$HOME/logs/login.log
|
export LOGIN_LOG=$HOME/logs/login.log
|
||||||
mkdir -p $HOME/logs
|
mkdir -p $HOME/logs
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
# echo ".bash_profile sourced at user $USER login"
|
# echo ".bash_profile sourced at user $USER login"
|
||||||
|
|
||||||
# only source .bashrc if interactive login shell
|
# only source .bashrc if interactive login shell
|
||||||
[[ $- == *i* ]] && [[ -f "$HOME/.bashrc" ]] && source "$HOME/.bashrc"
|
[[ $SHELL_INTERACTIVE ]] && [[ -f "$HOME/.bashrc" ]] && source "$HOME/.bashrc"
|
|
@ -1,7 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# echo "$USER .bashrc"
|
#uncomment these for debugging.
|
||||||
# processing user's shell repo if base was loaded
|
# echo ---- sourcing system .bashrc for user $USER ---
|
||||||
[[ $BASH_SHELL_BASE_LOADED = true ]] && \
|
# [[ $USER_ROOT ]] && echo 'Root User' || echo 'Non Root User'
|
||||||
export BASH_SHELL_USER=${BASH_SHELL_USER:-"bash/shell"} && \
|
# [[ $SHELL_INTERACTIVE ]] && echo 'Interactive' || echo 'Not interactive'
|
||||||
[[ -d $HOME/$BASH_SHELL_USER ]] && shell_process_directory "$HOME/$BASH_SHELL_USER" ||\
|
# [[ $SHELL_LOGIN ]] && echo 'Login shell' || echo 'Not login shell'
|
||||||
echo no user shell directory $HOME/$BASH_SHELL_USER to process, create one or clone a template
|
# [[ $SSH_SESSION ]] && echo ssh remote user || echo local user
|
||||||
|
# env | grep BASH
|
||||||
|
# echo ---------------------
|
||||||
|
|
||||||
|
if ( [[ $SHELL_INTERACTIVE ]] );then
|
||||||
|
if ( [[ $BASH_SHELL_BASE_LOADED = true ]] ) ; then
|
||||||
|
# echo loading user shell sources
|
||||||
|
export BASH_SHELL_USER=${BASH_SHELL_USER:-"bash/shell"}
|
||||||
|
[[ -d $HOME/$BASH_SHELL_USER ]] && shell_process_directory "$HOME/$BASH_SHELL_USER" ||\
|
||||||
|
echo no user shell directory $HOME/$BASH_SHELL_USER to process, create one or clone a template
|
||||||
|
fi
|
||||||
|
# uncomment to add non-interactive setup/sourcing
|
||||||
|
# else
|
||||||
|
# echo non-login and non-interactive
|
||||||
|
fi
|
||||||
|
|
||||||
|
# anything below will be sourced by all shell types (except non-interactive/login)
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
echo .profile, user $USER
|
echo .profile, user $USER
|
||||||
echo "this only is sourced if .bash_profile doesn't exist"
|
echo "warning: this only is sourced if .bash_profile doesn't exist"
|
Loading…
Reference in New Issue