From: Nicolas Boisselier Date: Thu, 4 Jul 2019 15:44:43 +0000 (+0100) Subject: etc/profile X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=17511c627b3ee5f06cc7735c194dde2241932b6d;p=nb.git etc/profile --- diff --git a/etc/profile.d/functions b/etc/profile.d/functions index d8978fc2..ed4b112c 100755 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -143,9 +143,18 @@ nb_repos_grep() { } nb_repos_ls_files() { + nb_repos | while read r; do + git -C "$r" ls-files --full-name | while read i; do + i="$r/$i" + [ ! -e "$i" -o -d "$i" ] && continue + echo $i + done + done + return 0 local i for i in `nb_repos`; do - git -C "$i" ls-files | sed -e "s!^!$i/!" -e "s!^//\+!/!" + #git -C "$i" ls-files | sed -e "s!^!$i/!" -e "s!^//\+!/!" + git -C "$i" ls-files --full-name | sed -e "s!^!$i/!" -e "s!^//\+!/!" done } diff --git a/etc/profile.d/net.sh b/etc/profile.d/net.sh index 106d6dfb..ec992af2 100644 --- a/etc/profile.d/net.sh +++ b/etc/profile.d/net.sh @@ -22,19 +22,28 @@ net_gateway_interface() { esac } -net_resolve() { - ( - if [ -t 0 ]; then - while [ $# -gt 0 ]; do - printf '%s\n' "$1" - shift - done - else - cat - fi - ) | perl -MSocket -pe 'BEGIN{sub ip2host{$i=shift;return $c{$i} if $c{$i};$h=gethostbyaddr(inet_aton($i),AF_INET);%c=()if keys(%c)>10000;return $c{$i}=$h?$h:$i;};}; s/(\b)(\d+(?:\.\d+){3})(\b)/$1.ip2host($2).$3/ge' +net_host2ip() { + host -s "$1" | awk '/has address/{print $4; exit}' +} + +net_ip2host() { + declare host="$(host -s "$1" | awk '/domain name pointer/{print $5; exit}')" + echo ${host%%.} } +# NB 27.06.19 net_resolve() { +# NB 27.06.19 ( +# NB 27.06.19 if [ -t 0 ]; then +# NB 27.06.19 while [ $# -gt 0 ]; do +# NB 27.06.19 printf '%s\n' "$1" +# NB 27.06.19 shift +# NB 27.06.19 done +# NB 27.06.19 else +# NB 27.06.19 cat +# NB 27.06.19 fi +# NB 27.06.19 ) | perl -MSocket -pe 'BEGIN{sub ip2host{$i=shift;return $c{$i} if $c{$i};$h=gethostbyaddr(inet_aton($i),AF_INET);%c=()if keys(%c)>10000;return $c{$i}=$h?$h:$i;};}; s/(\b)(\d+(?:\.\d+){3})(\b)/$1.ip2host($2).$3/ge' +# NB 27.06.19 } + net_cdr2mask() { # Number of args to shift, 255..255, first non-255 byte, zeroes eval 'set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0' @@ -50,15 +59,11 @@ net_mask2cdr() { echo $(( $2 + (${#x}/4) )) } -net_resolve_ip() { - host -s "$1" | awk '/has address/{print $4; exit}' -} - net_is_local() { declare ip="${1:?Usage: net_is_local IP|HOST}" case "$ip" in [0-9][0-9]?[0-9]?.[0-9][0-9]?[0-9]?.[0-9][0-9]?[0-9]?.[0-9][0-9]?[0-9]?) [ 1 ];; - *) ip="$(net_resolve_ip "$ip")" + *) ip="$(net_host2ip "$ip")" esac [ -n "$ip" ] || return 2 diff --git a/share/db/nb.db b/share/db/nb.db index c5d5000c..874f925b 100644 Binary files a/share/db/nb.db and b/share/db/nb.db differ diff --git a/share/db/update.sh b/share/db/update.sh index f963d92e..32569689 100755 --- a/share/db/update.sh +++ b/share/db/update.sh @@ -21,4 +21,4 @@ tables=${tables%,*} nb_api "/pub/dump/sqlite?table-name=$tables" echo 'VACUUM;' -) | sqlite3 "nb.db" +) #| sqlite3 "nb.db"