Skip to content

Instantly share code, notes, and snippets.

@sonwh98
Last active May 23, 2021 08:26
Show Gist options
  • Save sonwh98/37c76015d6f89a1597d3836777b1a9aa to your computer and use it in GitHub Desktop.
Save sonwh98/37c76015d6f89a1597d3836777b1a9aa to your computer and use it in GitHub Desktop.
parses ip address from ipconfig and generates url to update google hosted dynamic dns
(require '[clojure.java.shell :refer [sh]]
'[clojure.string :as string])
(let [out (:out (sh "ifconfig"))
wifi-device "wlp0s20f3"
i (string/index-of out wifi-device)
i (string/index-of out "inet" i)
j (string/index-of out "netmask" i)
inet (subs out i j)
[_ ip] (string/split inet #" ")
username "foo"
password "bar"
hostname "myhost"
url (format "https://%s:%s@domains.google.com/nic/update?hostname=%s&myip=%s" username password hostname ip)]
(println url)
(println "sudo systemd-resolve --flush-caches")
)
(System/exit 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment