diff options
-rwxr-xr-x | knot-resolver/bin/kresd-cache-clear | 29 | ||||
-rwxr-xr-x | knot/bin/knot-zones-reset | 94 |
2 files changed, 36 insertions, 87 deletions
diff --git a/knot-resolver/bin/kresd-cache-clear b/knot-resolver/bin/kresd-cache-clear index 49c2462..5b9a0e1 100755 --- a/knot-resolver/bin/kresd-cache-clear +++ b/knot-resolver/bin/kresd-cache-clear @@ -21,31 +21,10 @@ set -e -HOSTS="${*:-localhost}" +NUMBER="$(systemctl | grep -c 'kresd@[0-9].service')" -for HOST in ${HOSTS} +for NUMBER in $(seq 1 "${NUMBER}") do - case "${HOST}" in - localhost) - NUMBER="$(systemctl | grep -c 'kresd@[0-9].service')" - - for NUMBER in $(seq 1 "${NUMBER}") - do - echo "Flushing localhost, resolver ${NUMBER}" - echo "cache.clear()" | sudo socat - UNIX-CONNECT:/run/knot-resolver/control/"${NUMBER}" - done - ;; - - *) - NUMBER="$(ssh "${HOST}" sudo systemctl | grep -c 'kresd@[0-9].service')" - - for NUMBER in $(seq 1 "${NUMBER}") - do - echo "Flushing ${HOST}, resolver ${NUMBER}" - echo "cache.clear()" | ssh "${HOST}" sudo socat - UNIX-CONNECT:/run/knot-resolver/control/"${NUMBER}" - done - ;; - esac + echo "Flushing localhost, resolver ${NUMBER}" + echo "cache.clear()" | sudo socat - UNIX-CONNECT:/run/knot-resolver/control/"${NUMBER}" done - -echo diff --git a/knot/bin/knot-zones-reset b/knot/bin/knot-zones-reset index 63d38fd..8ab2dca 100755 --- a/knot/bin/knot-zones-reset +++ b/knot/bin/knot-zones-reset @@ -21,65 +21,35 @@ set -e -HOSTS="${*:-localhost}" - -for HOST in ${HOSTS} -do - case "${HOST}" in - localhost) - echo "Resetting in-memory data for all zones..." - - if systemctl status knot | grep -qs 'Active: active' - then - START="true" - sudo service knot stop - else - START="false" - fi - - sudo rm -rf /var/lib/knot/journal/*.mdb - sudo rm -rf /var/lib/knot/timers/*.mdb - - if [ -e /var/lib/knot/zones/.git ] - then - sudo chown -R root:root /var/lib/knot/zones/ - - cd /var/lib/knot/zones - sudo git clean -dxf - sudo git checkout -f - - sudo chown -R knot:knot /var/lib/knot/zones/ - fi - - case "${START}" in - true) - sudo service knot start - ;; - esac - - echo - echo "done." - ;; - - *) - echo "'${HOST}': Resetting in-memory data for all zones..." - - ssh "${HOST}" \ - "sudo service knot stop && \ - sudo rm -rf /var/lib/knot/journal/*.mdb && \ - sudo rm -rf /var/lib/knot/timers/*.mdb && \ - if [ -e /var/lib/knot/zones/.git ]; \ - then \ - sudo chown -R root:root /var/lib/knot/zones/; \ - cd /var/lib/knot/zones; \ - sudo git clean -dxf; \ - sudo git checkout -f; \ - sudo chown -R knot:knot /var/lib/knot/zones/; \ - fi; \ - sudo service knot start" - - echo - echo "done." - ;; - esac -done +echo "Resetting in-memory data for all zones..." + +if systemctl status knot | grep -qs 'Active: active' +then + START="true" + sudo service knot stop +else + START="false" +fi + +sudo rm -rf /var/lib/knot/journal/*.mdb +sudo rm -rf /var/lib/knot/timers/*.mdb + +if [ -e /var/lib/knot/zones/.git ] +then + sudo chown -R root:root /var/lib/knot/zones/ + + cd /var/lib/knot/zones + sudo git clean -dxf + sudo git checkout -f + + sudo chown -R knot:knot /var/lib/knot/zones/ +fi + +case "${START}" in + true) + sudo service knot start + ;; +esac + +echo +echo "done." |