]> git.nbdom.net Git - nb.git/commitdiff
etc/profile
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 4 Jul 2019 15:44:43 +0000 (16:44 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 4 Jul 2019 15:44:43 +0000 (16:44 +0100)
etc/profile.d/functions
etc/profile.d/net.sh
share/db/nb.db
share/db/update.sh

index d8978fc20114bcf65516f0a59a8464ff79d13620..ed4b112c452b5a638498f013bd925f0f1ba2ab3b 100755 (executable)
@@ -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
 }
 
index 106d6dfbfbc60e5dea40ae864e7847b5461cbe40..ec992af2c3f2a45ecf8e6300ba33a7d8e7aa6533 100644 (file)
@@ -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
index c5d5000c848b2bdd9161abfa530f2911ac57eac3..874f925b41e6efe21757a091aeff89d3852ac884 100644 (file)
Binary files a/share/db/nb.db and b/share/db/nb.db differ
index f963d92e1db75e4798accdac2961adc6ce8e8ae9..32569689d3943d57227d0dc0d6f61b140303493c 100755 (executable)
@@ -21,4 +21,4 @@ tables=${tables%,*}
        nb_api "/pub/dump/sqlite?table-name=$tables"
        echo 'VACUUM;'
 
-) | sqlite3 "nb.db"
+) #| sqlite3 "nb.db"