Last active
May 23, 2021 08:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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