summaryrefslogtreecommitdiffstats
path: root/knot/bin/knot-zones-reset
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-08 15:06:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-08 15:06:13 +0000
commita54c362dff0e8c1993bb19a992544bcfa9cb44e2 (patch)
tree41e0d6053480510a4f1eafbc0d8256ad929b5a45 /knot/bin/knot-zones-reset
parentAdding upstream version 20221101. (diff)
downloadopen-infrastructure-service-tools-a54c362dff0e8c1993bb19a992544bcfa9cb44e2.tar.xz
open-infrastructure-service-tools-a54c362dff0e8c1993bb19a992544bcfa9cb44e2.zip
Adding upstream version 20221108.upstream/20221108
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'knot/bin/knot-zones-reset')
-rwxr-xr-xknot/bin/knot-zones-reset84
1 files changed, 32 insertions, 52 deletions
diff --git a/knot/bin/knot-zones-reset b/knot/bin/knot-zones-reset
index 6471cf4..8ab2dca 100755
--- a/knot/bin/knot-zones-reset
+++ b/knot/bin/knot-zones-reset
@@ -21,55 +21,35 @@
set -e
-HOSTS="${*:-localhost}"
-
-for HOST in ${HOSTS}
-do
- case "${HOST}" in
- localhost)
- 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
-
- sudo service knot start
-
- 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."