diff options
Diffstat (limited to 'knot')
-rwxr-xr-x | knot/bin/knot-zones-reset (renamed from knot/bin/knot-reset-zones) | 51 | ||||
-rwxr-xr-x | knot/share/cron/knot-reset-zones | 3 | ||||
-rwxr-xr-x | knot/share/cron/knot-zones-reset | 3 |
3 files changed, 37 insertions, 20 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 diff --git a/knot/share/cron/knot-reset-zones b/knot/share/cron/knot-reset-zones deleted file mode 100755 index 9762da4..0000000 --- a/knot/share/cron/knot-reset-zones +++ /dev/null @@ -1,3 +0,0 @@ -# /etc/cron.d/knot-reset-zone - -0 0 * * * root /usr/bin/knot-reset-zones localhost > /dev/null 2>&1 diff --git a/knot/share/cron/knot-zones-reset b/knot/share/cron/knot-zones-reset new file mode 100755 index 0000000..13dfd44 --- /dev/null +++ b/knot/share/cron/knot-zones-reset @@ -0,0 +1,3 @@ +# /etc/cron.d/knot-zones-reset + +0 0 * * * root /usr/bin/knot-zones-reset > /dev/null 2>&1 |