diff options
author | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2022-10-30 10:28:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2022-10-30 12:38:01 +0000 |
commit | efba3be1636b0dd534859ba2816fcc231c4f8ca4 (patch) | |
tree | c9cdd2d1038a1dafcecedadb6f7cfea08abbfd73 /knot/bin/knot-zones-reset | |
parent | Providing individual root and intermediate certificate files in dehydrated ex... (diff) | |
download | service-tools-efba3be1636b0dd534859ba2816fcc231c4f8ca4.tar.xz service-tools-efba3be1636b0dd534859ba2816fcc231c4f8ca4.zip |
Reworking knot-zones-reset script.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-x | knot/bin/knot-zones-reset (renamed from knot/bin/knot-reset-zones) | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/knot/bin/knot-reset-zones b/knot/bin/knot-zones-reset index 40779cf..6471cf4 100755 --- a/knot/bin/knot-reset-zones +++ b/knot/bin/knot-zones-reset @@ -21,38 +21,55 @@ set -e -HOSTS="${*}" - -if [ -z "${HOSTS}" ] -then - echo "Usage: ${0} localhost|[HOST1 HOST2 ...]" >&2 - exit 1 -fi +HOSTS="${*:-localhost}" for HOST in ${HOSTS} do case "${HOST}" in localhost) - echo -n "Resetting in-memory data for all zones..." + echo "Resetting in-memory data for all zones..." + + 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 - service knot stop - rm -rf /var/lib/knot/journal/*.mdb - rm -rf /var/lib/knot/timers/*.mdb - service knot start + sudo service knot start - echo " done." + echo + echo "done." ;; *) - echo -n "'${HOST}': Resetting in-memory data for all zones..." + echo "'${HOST}': Resetting in-memory data for all zones..." ssh "${HOST}" \ "sudo service knot stop && \ - rm -rf /var/lib/knot/journal/*.mdb && \ - rm -rf /var/lib/knot/timers/*.mdb && \ + 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 " done." + echo + echo "done." ;; esac done |