From b20224c08447c73e36a98c844aa3013591c01e39 Mon Sep 17 00:00:00 2001 From: Gilles Mouchet Date: Sat, 1 Jun 2024 09:21:00 +0200 Subject: [PATCH] change gmo-cfg.sh --- files/os/gmo-cfg.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/files/os/gmo-cfg.sh b/files/os/gmo-cfg.sh index afb2ac6..e703fbd 100644 --- a/files/os/gmo-cfg.sh +++ b/files/os/gmo-cfg.sh @@ -1,3 +1,17 @@ +# source IA +# check if is a scp connexion +is_scp() { + # If SSH_ORIGINAL_COMMAND is defined and contains "scp" + if [[ -n "$SSH_ORIGINAL_COMMAND" && "$SSH_ORIGINAL_COMMAND" == scp* ]]; then + return 0 + fi + # if script name ($0) contains "scp" + if [[ "$0" == *scp* ]]; then + return 0 + fi + return 1 +} + # source prompt color: https://robotmoon.com/bash-prompt-generator/^ if [ $(whoami) == "gilles" ]; then #export PS1="\[\033[0;32m\][\[\033[1;94m\]\u\[\033[0;33m\]@\h \[\033[0;32m\]\W]# \[\033[0;37m\]" @@ -17,13 +31,16 @@ alias mv='mv -i' alias ls='ls --color=auto' alias sudo='sudo --preserve-env=PATH env' # https://www.petefreitag.com/blog/environment-variables-sudo/ -if [[ "$USER" == "gilles" || "$USER" == "root" ]]; then - dist=$(cat /etc/redhat-release) - kern=$(uname -r) - cat << EOF +if [ ! is_scp ]; then + if [[ "$USER" == "gilles" || "$USER" == "root" ]]; then + dist=$(cat /etc/redhat-release) + kern=$(uname -r) + cat << EOF + Distribution: $dist Kernel: $kern EOF + fi fi # execute only if user is gilles or root #if [[ "$USER" == "gilles" || "$USER" == "root" ]]; then