add support for sourcing for remote shell via ssh. Works for both interactive and non-interactive

added support for alises in non-interactive shell via bash.bashrc
add TODO markdown file to track desired changes
master
David Kebler 2020-11-23 15:14:18 -08:00
parent 01b8894dd2
commit cae3a94dd8
7 changed files with 21 additions and 8 deletions

4
TODO.md Normal file
View File

@ -0,0 +1,4 @@
# TODOS
add ability to disable loading shell repos
add ability to disable alias in non-interactive and interactive shells

View File

@ -53,6 +53,7 @@ function shell_process_directory () {
local SUBDIRS
local IGNORE_FILE
SUBDIRS=$([[ -f "$DIR/.bash-shell-include" ]] && cat "$DIR/.bash-shell-include" || echo $BASH_SHELL_BASE_SUBDIRS)
[[ $SSH_LOGIN ]] && SUBDIRS+=" ssh"
IGNORE_FILE="$([[ -f "$DIR/.bash-shell-ignore" ]] && echo "$DIR" || echo "$BASH_SHELL_BASE")/.bash-shell-ignore"
for SUBDIR in $SUBDIRS; do
if [ -e "$DIR/$SUBDIR" ]; then

View File

@ -1,7 +1,8 @@
#!/bin/bash
_USER=${1:-USER}
_USER=${1:-$USER}
[[ ! $(id -u $_USER) -ge 1000 ]] && echo "no user $_USER or user not a regular" && exit 1
echo user: $_USER deployment
[[ ! $BASH_SHELL_BASE ]] && BASH_SHELL_BASE="$(dirname "$(cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")"
echo Base Shell Directory as detected is $BASH_SHELL_BASE
echo ok to continue?

View File

@ -4,8 +4,12 @@
# [ $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 ----
# echo sourcing $BASH_SHELL_LOAD
# ([ -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
export SSH_SESSION=true
source /etc/profile
fi
shopt -s expand_aliases
source $BASH_SHELL_LOAD

View File

@ -22,9 +22,9 @@ export BASH_SHELL_BASE=THISWILLCHANGEDBYDEPLOYSCRIPT
# uncomment to NOT load the BASH SHELL Repos for interactive login shell
# NO_LOGIN_BASHRC=true
if [[ $- == *i* ]]; then # interactive?
echo interactive login shell
[[ ! $SSH_SESSION ]] && echo interactive login shell
if [[ ! $NO_LOGIN_BASHRC ]]; then
# echo loading $BASH_SHELL_LOAD
# echo interactive shell loading $BASH_SHELL_LOAD
source "$BASH_SHELL_LOAD"
else
NORMAL="\[\e[0m\]"
@ -38,7 +38,7 @@ if [[ $- == *i* ]]; then # interactive?
unset RED GREEN NORMAL
fi
else
if [[ $EUID -ne 0 ]]; then
if [[ $EUID -ne 0 ]] && [[ ! $SSH_SESSION ]]; then
export LOGIN_LOG=$HOME/logs/login.log
mkdir -p $HOME/logs
touch $LOGIN_LOG

View File

@ -43,6 +43,8 @@ export BASH_SHELL_STARTUP=$BASH_SHELL_BASE/startup.sh # strtup.sh is default
# shopt -u expand_aliases
####################
([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]) && export SSH_SESSION=true
# identify a network name that this host resides on
# make a directory of the same name
# if unset then only /all will be sourced

1
ssh/readme.md Normal file
View File

@ -0,0 +1 @@
*this will be sourced if this is a an ssh login session*