From: Nicolas Boisselier Date: Wed, 17 Jan 2018 06:26:38 +0000 (+0000) Subject: etc/profile.d/nb.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=8744e57e194bcc745046041b337e63d64b61ec28;p=nb.git etc/profile.d/nb.sh --- diff --git a/etc/profile.d/nb.sh b/etc/profile.d/nb.sh index 24b5071f..72bf33fd 100644 --- a/etc/profile.d/nb.sh +++ b/etc/profile.d/nb.sh @@ -1,5 +1,5 @@ export NB_DB=nb -NB_AUTH=$(awk '/^machine api.nbdom.net / { print $4":"$6}' $HOME/.netrc 2> /dev/null) +#NB_AUTH=$(awk '/^machine api.nbdom.net / { print $4":"$6}' $HOME/.netrc 2> /dev/null) #=SHELL_REPLACE sudo awk -F '}' '/CLEARTEXT/{print "NB_AUTH=\"nb:"$2"\""}' /etc/ldap/nbdom.net/auth/nb.ldif [ -z "$NB_AUTH" ] && NB_AUTH="nb:0TXARcQUpjHZctoROA2X.weWSZKM5DGT" export NB_AUTH @@ -83,9 +83,12 @@ nb_php() { nb_api() { local uri="$1"; shift - #local auth; [ -n "$NB_AUTH" ] && auth='-u "'$NB_AUTH'"' - #curl --netrc-optional -s "$auth" "https://api.nbdom.net$uri" "$@" - curl --netrc-optional -su "$NB_AUTH" "https://api.nbdom.net$uri" "$@" + if [ -z "$NB_AUTH" -o x = x$(awk '/^machine api.nbdom.net / { print $4":"$6}' $HOME/.netrc 2> /dev/null) ]; then + curl -su "$NB_AUTH" "https://api.nbdom.net$uri" "$@" + else + curl -su "$NB_AUTH" "https://api.nbdom.net$uri" "$@" + #curl --netrc-optional "https://api.nbdom.net$uri" "$@" + fi } nb_api_post() {