From 6ce9e0417aee7819df5c4781729ff48ab4202690 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 31 Aug 2016 18:20:50 +0200 Subject: [PATCH] compatible --- etc/profile | 12 +++++++++++- etc/profile.d/functions | 10 +++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/etc/profile b/etc/profile index 7f203765..db2a759d 100644 --- a/etc/profile +++ b/etc/profile @@ -3,29 +3,39 @@ # #[ "$1" = "--debug" ] && NB_DEBUG='eval echo 1>&2 "$(basename $BASH_SOURCE): "' && shift [ "$1" = "--debug" ] && NB_DEBUG='echo NB_DEBUG:' && shift +#NB_DEBUG='echo NB_DEBUG:' if [ -n "$NB_LOOP" ]; then [ -n "$NB_DEBUG" ] && $NB_DEBUG "NB_LOOP=$NB_LOOP: BASH_SOURCE=$BASH_SOURCE \$0=$0" NB_LOOP=$(($NB_LOOP+1)) return fi export NB_LOOP=1 +#set | grep profile # # SEARCH ROOT # -dir='.' +dir='' case "$BASH_SOURCE" in */*) dir="${BASH_SOURCE%/*}";; *) if [ -n "$ZSH_NAME" ]; then dir=${(%):-%N} dir=${dir%/*} + elif [ -r /etc/profile.d/nb.sh ]; then + dir=$(dirname $(cut -d'.' -f2 /etc/profile.d/nb.sh)) fi ;; esac +if [ -z "$dir" ]; then + [ -n "$NB_DEBUG" ] && $NB_DEBUG "Can't find NB_ROOT" + return 0 +fi [ -e "$dir/profile.d/functions" ] && . "$dir/profile.d/functions" NB_ROOT=$(realpath ${dir}/.. 2>/dev/null) +#echo $NB_ROOT +#echo $NB_ROOT #echo "$NB_ROOT: `pwd`" unset dir diff --git a/etc/profile.d/functions b/etc/profile.d/functions index 2509a58b..c742d943 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -71,7 +71,8 @@ shell_ssh() { esac else - ssh $ssh_opt "$server" "bash && rm -f $tmp" <<< ". $tmp; $@" +# NB 31.08.16 ssh $ssh_opt "$server" "bash && rm -f $tmp" <<< ". $tmp; $@" + echo ". $tmp; $@" | ssh $ssh_opt "$server" "bash && rm -f $tmp" fi } @@ -347,7 +348,8 @@ cron_d_install() { tmp="/tmp/$FUNCNAME.$$" trap "rm -f $tmp*" EXIT file="$tmp.cron" - cat <<< "$1" > "$file"; shift +# NB 31.08.16 cat <<< "$1" > "$file"; shift + echo "$1" > "$file"; shift exp=$1; shift else @@ -421,7 +423,8 @@ exit $diff ? 0 : 1; echo ": Not changed; return 1" fi - [ "$cron" != "$(crontab -l)" ] && crontab <<< "$cron" +# NB 31.08.16 [ "$cron" != "$(crontab -l)" ] && crontab <<< "$cron" + [ "$cron" != "$(crontab -l)" ] && echo "$cron" | crontab } @@ -531,6 +534,7 @@ ssl_cert_create() { urlencode() { local length="${#1}" for (( i = 0; i < length; i++ )); do + #for i in `seq 0 $(($length-1))`; do local c="${1:i:1}" case $c in [a-zA-Z0-9.~_-]) printf "$c" ;; -- 2.47.3