executable_mj-hosts.sh 788 B

1234567891011121314
  1. #!/bin/sh
  2. set -e -x
  3. # ssh router <<< busybox 'grep 172.16. /tmp/etc/hosts.dnsmasq' && exit 0
  4. dig @172.16.103.2 -tAXFR intr | awk '/\tA\t/ {print $NF" "$1}' | sort | sed -e 's|.intr.||g' | awk '{print $1" "$2" "$2".intr"}' > /tmp/mj.zone
  5. dig @172.16.103.2 -tAXFR intr | awk '/CNAME/ {print system("dig +short "$NF "| tail -1 | xargs echo -n ")" " $1}' | sed -e 's:0 : :' -e 's|.intr.||' | awk '/172/ {print $1" "$2" "$2".intr"}' >> /tmp/mj.zone
  6. # scp /tmp/mj.zone router:/tmp/
  7. # ssh router <<< busybox 'grep 172.16. /tmp/etc/hosts.dnsmasq' || ssh router <<< busybox 'cat /tmp/mj.zone >> /tmp/etc/hosts.dnsmasq'
  8. # ssh router <<< busybox 'kill -HUP $(pidof dnsmasq)'
  9. # ssh router <<< busybox 'rm /tmp/mj.zone'
  10. #ssh router <<< busybox 'touch /tmp/mjlocked'
  11. # rm -f /tmp/mj.zone