This repository has been archived on 2022-02-20. You can view files and clone it, but cannot push or open issues or pull requests.
bash-shell-base/setup/etc/profile
David Kebler 5e45c1f23a refactored script sourcing exludes to .bash-shell-ignore file
refacted load.sh and startup.sh accordingly and also used loop to process the shell repos
switched from export to declare for module.lib
allows multiple network domains to be set in shell.env.  This allows primary and vpn setups
moved docker and language files out of base
added comment functions
2020-11-18 15:32:09 -08:00

62 lines
1.8 KiB
Bash

#!/bin/bash
# put no script code directly here.
# organize all script code in files /etc/profile.d
# uncomment for debugging
# echo ---- system profile /etc/profile sourced at login ----
# [ $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'
# echo -----------
# main /etc/profile loaded for all logins
# more info see http://www.linuxfromscratch.org/blfs/view/svn/postlfs/profile.html
# Set the initial path
export PATH=/bin:/usr/bin:/usr/local/bin
# set directory for base shell repo
export BASH_SHELL_BASE=/opt/bash/shell/base # where
# now bootstrap by souring the shell repo envinroment
. $BASH_SHELL_BASE/shell.env
# uncomment to NOT load the BASH SHELL Repos for interactive login shell
# NO_LOGIN_BASHRC=true
if [[ $- == *i* ]]; then # interactive?
echo interactive login shell
if [[ ! $NO_LOGIN_BASHRC ]]; then
echo loading $BASH_SHELL_LOAD
source "$BASH_SHELL_LOAD"
else
NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
if [[ $EUID == 0 ]] ; then
PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
else
PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
fi
unset RED GREEN NORMAL
fi
else
if [[ $EUID -ne 0 ]]; then
export LOGIN_LOG=$HOME/logs/login.log
mkdir -p $HOME/logs
touch $LOGIN_LOG
llog () {
echo "$@" 2>&1 | tee -a $LOGIN_LOG
}
export -f llog
llog "$(env | grep BASH)"
echo "$(date)" > $LOGIN_LOG
llog "non-interactive login shell for $USER"
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
llog "sourcing $i"
source $i
fi
done
unset i
fi
fi
fi