From d5c89e284e5e9c0d793bfdda00c3b2175341d06e Mon Sep 17 00:00:00 2001 From: David Kebler Date: Mon, 14 Oct 2024 12:51:12 -0700 Subject: [PATCH] fix .bashrc for root so it loads uci correctly --- install/files/root/.bashrc | 43 +++++++++++++++++++++----------- install/files/user/.bash_profile | 21 ++++++++-------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/install/files/root/.bashrc b/install/files/root/.bashrc index 51a69c4..77a82ec 100644 --- a/install/files/root/.bashrc +++ b/install/files/root/.bashrc @@ -1,6 +1,5 @@ -# this .bashrc for use ONLY with uci bash shell system - -# uncomment these for debugging. +#!/bin/bash +#uncomment these for debugging. # echo ---- sourcing system .bashrc for user $USER --- # [[ $USER_ROOT ]] && echo 'Root User' || echo 'Non Root User' # [[ $SHELL_INTERACTIVE ]] && echo 'Interactive' || echo 'Not interactive' @@ -9,16 +8,32 @@ # env | grep BASH # echo --------------------- +# should always be true but check anyway +if ( [[ $SHELL_INTERACTIVE ]] );then + if ( [[ $BASH_SHELL_BASE_LOADED = true ]] ) ; then + if [[ $BASH_SHELL_USER_DIR ]]; then + # echo loading user $USER shell at $BASH_SHELL_USER_DIR + if [[ -d $BASH_SHELL_USER_DIR ]]; then + shell_process_directory "$BASH_SHELL_USER_DIR" + else + echo no user shell directory at $BASH_SHELL_USER_DIR to process + echo creating one now + declare dir + mkdir -p $BASH_SHELL_USER_DIR + for dir in $(cat $BASH_SHELL_BASE/.bash-shell-include); do + mkdir -p $BASH_SHELL_USER_DIR/$dir + done + fi + else + echo WARNING! user environment variable BASH_SHELL_USER_DIR was not set in $BASH_SHELL_BASE/shell.env + echo user uci shell will not load + fi + fi + # uncomment to add non-interactive setup/sourcing + # else + # echo non-login and non-interactive +fi -# uncomment for custom processing -#if [[ $SHELL_LOGIN ]]; then -# echo "login shell (called from .bash_profile)" -# fi - -if [[ $SSH_SESSION ]]; then -# echo remote ssh session - cd /opt - fi - +# anything below will be sourced whether or not UCI shell was invoked # anything below will be sourced by all shell types (except non-interactive/login) -export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin +export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin \ No newline at end of file diff --git a/install/files/user/.bash_profile b/install/files/user/.bash_profile index 862c145..039e7d3 100644 --- a/install/files/user/.bash_profile +++ b/install/files/user/.bash_profile @@ -11,17 +11,18 @@ # echo --------------------- -# only source .bashrc if interactive login shell -if [[ $SHELL_INTERACTIVE ]]; then - [[ -f "/root/.bashrc" ]] && source "/root/.bashrc" - else - export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin -fi - # only source .bashrc if interactive login shell if [[ $SHELL_INTERACTIVE ]];then [[ -f "$HOME/.bashrc" ]] && source "$HOME/.bashrc" else - # noninteractive login shell - : - fi \ No newline at end of file + export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin + fi + + +# delete? +# only source .bashrc if interactive login shell +# if [[ $SHELL_INTERACTIVE ]]; then +# [[ -f "/root/.bashrc" ]] && source "/root/.bashrc" +# else +# export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin +# fi \ No newline at end of file