executable_dnscheck 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/run/current-system/profile/bin/guile \
  2. --no-auto-compile -e (dnscheck) -s
  3. !#
  4. ;;;; dnscheck --- https://github.com/NorfairKing/dnscheck wrapper
  5. ;;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com>
  6. ;;;; Released under the GNU GPLv3 or any later version.
  7. (define-module (dnscheck)
  8. #:use-module (json)
  9. #:use-module (srfi srfi-1)
  10. #:use-module (srfi srfi-37)
  11. #:export (main))
  12. ;;; Commentary:
  13. ;;;
  14. ;;; DESCRIPTION
  15. ;;;
  16. ;;; Code:
  17. (define %options
  18. (let ((display-and-exit-proc (lambda (msg)
  19. (lambda (opt name arg loads)
  20. (display msg) (quit)))))
  21. (list (option '(#\v "version") #f #f
  22. (display-and-exit-proc "dnscheck version 0.0.1\n"))
  23. (option '(#\h "help") #f #f
  24. (display-and-exit-proc
  25. "Usage: dnscheck ...\n")))))
  26. (define %default-options
  27. '())
  28. (define %home
  29. (and=> (getenv "HOME")
  30. (lambda (home)
  31. home)))
  32. (define (main args)
  33. (define opts
  34. (args-fold (cdr (program-arguments))
  35. %options
  36. (lambda (opt name arg loads)
  37. (error "Unrecognized option `~A'" name))
  38. (lambda (op loads)
  39. (cons op loads))
  40. %default-options))
  41. (define json-filename
  42. (port-filename (mkstemp "/tmp/dnscheck-json-XXXXXX")))
  43. (with-output-to-file json-filename
  44. (lambda _
  45. (display (scm->json-string (load (last args))))))
  46. (system* (string-append %home "/.nix-profile/bin/dnscheck") json-filename)
  47. (delete-file json-filename))
  48. ;;; dnscheck ends here