summaryrefslogtreecommitdiffstats
path: root/knot/bin/knot-reset-zones
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xknot/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