]> git.nbdom.net Git - nb.git/commitdiff
compatible
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 31 Aug 2016 16:20:50 +0000 (18:20 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 31 Aug 2016 16:20:50 +0000 (18:20 +0200)
etc/profile
etc/profile.d/functions

index 7f20376512246ce8856fa916ceca508c6a3be5fa..db2a759d4259298a892425d89e1544832680c4b8 100644 (file)
@@ -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
index 2509a58bc29fb1c359a1b45b2fdb22eb8c473377..c742d943f50a80e7920d12530af8d03c4d87ef21 100644 (file)
@@ -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" ;;