search for root.key and dlv.isc.org.key in /etc/swede
[public/dnssec-swede-utility.git] / swede
diff --git a/swede b/swede
index bcf4d40c6905e892891968c0a0081a9d5ce1bf16..cd212a4c38b5595c387f9b4e7f9d89e25898f34c 100755 (executable)
--- a/swede
+++ b/swede
@@ -17,6 +17,7 @@
 
 import sys
 import os
+import os.path
 import socket
 import unbound
 import re
@@ -132,8 +133,22 @@ def getRecords(hostname, rrtype='A', secure=True):
        """Do a lookup of a name and a rrtype, returns a list of binary coded strings. Only queries for rr_class IN."""
        global resolvconf
        ctx = unbound.ub_ctx()
-       ctx.add_ta_file('root.key')
-       ctx.set_option("dlv-anchor-file:", "dlv.isc.org.key")
+       if os.path.exists("root.key"):
+               ctx.add_ta_file('root.key')
+       elif os.path.exists("/etc/swede/root.key"):
+               ctx.add_ta_file('/etc/swede/root.key')
+       else:
+               print "Cannot find root.key, please move it to /etc/swede"
+               sys.exit()
+
+       if os.path.exists("dlv.isc.org.key"):
+               ctx.set_option("dlv-anchor-file:", "dlv.isc.org.key")
+       elif os.path.exists("/etc/swede/dlv.isc.org.key"):
+               ctx.set_option("dlv-anchor-file:", "/etc/swede/dlv.isc.org.key")
+       else:
+               print "Cannot find dlv.isc.org.key, please move it to /etc/swede"
+               sys.exit()
+
        # Use the local cache
        if resolvconf and os.path.isfile(resolvconf):
                ctx.resolvconf(resolvconf)