From 733bd082a1dfb76f8835bb37b8f02c1a1d37a36a Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Fri, 29 Mar 2019 01:27:11 +0000 Subject: [PATCH] etc/profile.d/functions --- etc/profile.d/functions | 56 +++++++++++++++++++-------------------- lib/nb-update/repo.sh | 1 + lib/postgres/nginx_var.sh | 2 +- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/etc/profile.d/functions b/etc/profile.d/functions index 96c3be7f..73275331 100755 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -23,34 +23,34 @@ which timeout > /dev/null || timeout() { which realpath > /dev/null || realpath() { #perl -MFile::Spec -MCwd -e 'print File::Spec->rel2abs( Cwd::abs_path($ARGV[0]) )."\n" if -e $ARGV[0]' "$1" - local pwd_bak=$PWD + local pwd_bak=$PWD - [ -e "$1" ] || return + [ -e "$1" ] || return - if [ -d "$1" ]; then - cd "$1" || return - pwd -P + if [ -d "$1" ]; then + cd "$1" || return + pwd -P else - local BASENAME="$(basename "$1")" - local LINK=$(readlink "$BASENAME") - cd "$(dirname "$1")" + local BASENAME="$(basename "$1")" + local LINK=$(readlink "$BASENAME") + cd "$(dirname "$1")" - while [ "$LINK" ]; do - cd "$(dirname "$LINK")" - LINK=$(readlink "$BASENAME") - done + while [ "$LINK" ]; do + cd "$(dirname "$LINK")" + LINK=$(readlink "$BASENAME") + done - local DIR="$(pwd -P)" - if [ "$DIR" = "/" ]; then - echo "$DIR$BASENAME" - else - echo "$DIR/$BASENAME" - fi + local DIR="$(pwd -P)" + if [ "$DIR" = "/" ]; then + echo "$DIR$BASENAME" + else + echo "$DIR/$BASENAME" + fi - fi + fi - cd "$pwd_bak" + cd "$pwd_bak" } # NB 12.03.19 if ! which realpath > /dev/null; then @@ -850,14 +850,14 @@ cron_d_install() { # root 20.03.19 shell_help_noarg "$usage" "--help" && return 1 # NB 20.03.19 #elif [ $# -eq 3 ]; then -# NB 20.03.19 elif [ ! -e "$1" ]; then -# NB 20.03.19 fname=$1; shift -# NB 20.03.19 tmp="/tmp/cron_d_install.$$" -# NB 20.03.19 trap "rm -f $tmp*" RETURN -# NB 20.03.19 file="$tmp.cron" -# root 20.03.19 cat <<< "$1" > "$file"; shift -# NB 20.03.19 echo "$1" > "$file"; shift -# NB 20.03.19 exp=$1; shift + elif [ ! -e "$1" ]; then + fname=$1; shift + tmp="/tmp/cron_d_install.$$" + trap "rm -f $tmp*" RETURN + file="$tmp.cron" +# NB 29.03.19 # root 20.03.19 cat <<< "$1" > "$file"; shift + echo "$1" > "$file"; shift + exp=$1; shift else file=$1; shift diff --git a/lib/nb-update/repo.sh b/lib/nb-update/repo.sh index a9d83791..af1b646c 100644 --- a/lib/nb-update/repo.sh +++ b/lib/nb-update/repo.sh @@ -12,3 +12,4 @@ git_change_url "git@git.nbdom.net:root.git" "git.nbdom.net:/home/git/root.git" git_change_url "git@git.nbdom.net:nbdom.git" "git.nbdom.net:/home/git/nbdom.git" git_change_url "pi.vpn.nbdom.net:/backups/big/home/git/puppet.git" "git@big.nbdom.net:puppet.git" #git_change_url "git@git.nbdom.net:pi.git" "git.nbdom.net:/home/git/pi.git" +return 0 diff --git a/lib/postgres/nginx_var.sh b/lib/postgres/nginx_var.sh index 0acb6653..442b42bc 100755 --- a/lib/postgres/nginx_var.sh +++ b/lib/postgres/nginx_var.sh @@ -2,5 +2,5 @@ http_get https://nginx.org/en/docs/varindex.html \ | xmllint --html --xpath "/html/body//div[@id=\"content\"]//p" - 2>/dev/null \ | sed -E -e "s,([^<]+) *(\(([^\)]+)\))?,https://nginx.org/en/docs/\1\t\2\t\4\n,g" -e "s,<[^>]+>,,g" \ -| grep -v "^ *$" sed "s,(\([^(]\+\))$,\1,g" \ +| grep -v "^ *$" | sed "s,(\([^(]\+\))$,\1,g" \ | awk 'BEGIN{FS="\t"}{print $2"\t"$3"\t"$1}' \ -- 2.47.3