From 1304c3afe7265c87628cc3c8b328af927f87e79e Mon Sep 17 00:00:00 2001 From: David Kebler Date: Wed, 2 Dec 2020 10:26:41 -0800 Subject: [PATCH] moved ssh session sourcing the ssh/session directory backup script picks up BASH_SHELL_BASE from script directory --- load.sh | 2 +- setup/backup.sh | 17 +++++++++++------ ssh/readme.md | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/load.sh b/load.sh index 7dc3d1a..1620afd 100755 --- a/load.sh +++ b/load.sh @@ -65,7 +65,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_SESSION ]] && SUBDIRS+=" ssh" + [[ $SSH_SESSION ]] && SUBDIRS+=" ssh/session" 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 diff --git a/setup/backup.sh b/setup/backup.sh index 522f604..711f708 100755 --- a/setup/backup.sh +++ b/setup/backup.sh @@ -1,19 +1,24 @@ #!/bin/bash [[ ! $(groups | grep sudo) ]] && echo this script must be run by a user with sudo privileges && exit 1 -[[ ! $BASH_SHELL_BASE ]] && echo "set BASH_SHELL_BASE before running this script" && exit 2 || echo backing up shell files... +[[ ! $BASH_SHELL_BASE ]] && BASH_SHELL_BASE="$(dirname "$(cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")" +echo Backng up to $BASH_SHELL_BASE/setup/backup +echo ok to continue? +echo "type \`yes\` fully or just for no" +read -e answer +[[ ! $answer = "yes" ]] && exit 1 set -o errexit mkdir -p $BASH_SHELL_BASE/setup/backup/etc/profile.d -mkdir -p $BASH_SHELL_BASE/setup/backup/user +# mkdir -p $BASH_SHELL_BASE/setup/backup/user mkdir -p $BASH_SHELL_BASE/setup/backup/root # host system files in /etc [[ -f /etc/profile ]] && cp -v /etc/profile $BASH_SHELL_BASE/setup/backup/etc [[ -f /etc/bash.bashrc ]] && cp -v /etc/bash.bashrc $BASH_SHELL_BASE/setup/backup/etc [[ -d /etc/profile.d ]] && cp -vR /etc/profile.d/ $BASH_SHELL_BASE/setup/backup/etc/ # current user files in $HOME -[[ -f $HOME/.bash_profile ]] && cp -v $HOME/.bash_profile $BASH_SHELL_BASE/setup/backup/user -[[ -f $HOME/.profile ]] && cp -v $HOME/.profile $BASH_SHELL_BASE/setup/backup/user -[[ -f $HOME/.bashrc ]] && cp -v $HOME/.bashrc $BASH_SHELL_BASE/setup/backup/user -[[ -f $HOME/.bash_logout ]] && cp -v $HOME/.bash_logout $BASH_SHELL_BASE/setup/backup/user +# [[ -f $HOME/.bash_profile ]] && cp -v $HOME/.bash_profile $BASH_SHELL_BASE/setup/backup/user +# [[ -f $HOME/.profile ]] && cp -v $HOME/.profile $BASH_SHELL_BASE/setup/backup/user +# [[ -f $HOME/.bashrc ]] && cp -v $HOME/.bashrc $BASH_SHELL_BASE/setup/backup/user +# [[ -f $HOME/.bash_logout ]] && cp -v $HOME/.bash_logout $BASH_SHELL_BASE/setup/backup/user if [[ $(stat -c "%G" /root) = "sudo" ]]; then [[ -f /root/.bash_profile ]] && cp -v /root/.bash_profile $BASH_SHELL_BASE/setup/backup/root [[ -f /root/.profile ]] && cp -v /root/.profile $BASH_SHELL_BASE/setup/backup/root diff --git a/ssh/readme.md b/ssh/readme.md index c56107f..168ba5e 100644 --- a/ssh/readme.md +++ b/ssh/readme.md @@ -1 +1 @@ -*this will be sourced if this is a an ssh login session* +*anything in /session will be sourced if this is a remote ssh login session*