summary refs log tree commit diff
path: root/bin/sup.sh
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-01-12 22:46:54 -0500
committerJune McEnroe <june@causal.agency>2022-01-12 22:46:54 -0500
commit2e195fa7f1e8159b274f1a65962dd5804c097566 (patch)
tree7ae49b42a8d45965b22c0b0135ccb4ab834949ad /bin/sup.sh
parentPublish "Books 2021" (diff)
downloadsrc-2e195fa7f1e8159b274f1a65962dd5804c097566.tar.gz
src-2e195fa7f1e8159b274f1a65962dd5804c097566.zip
Add LWN to sup
Diffstat (limited to 'bin/sup.sh')
-rw-r--r--bin/sup.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/sup.sh b/bin/sup.sh
index ae369e36..32e282d1 100644
--- a/bin/sup.sh
+++ b/bin/sup.sh
@@ -203,6 +203,34 @@ lobsters() {
 	open "${lobstersBase}/login"
 }
 
+lwn() {
+	username=$email
+	echo 'Submitting form...'
+	curl -Ss -X POST -F "username=${username}" \
+		'https://lwn.net/Login/MailPWLink' \
+		>/dev/null
+	echo 'Waiting for email...'
+	key=$(
+		git fetch-email -i -M Trash \
+			-F 'lwn@lwn.net' -S 'A link to set your LWN.net password' |
+		sed -n 's|.*/Login/SetPassword/.*/\(.*\)|\1|p'
+	)
+	echo 'Retrieving UID...'
+	uid=$(
+		curl -Ss "https://lwn.net/Login/SetPassword/${username}/${key}" |
+		sed -n 's/.*name="uid" value="\([^"]*\)".*/\1/p'
+	)
+	password=$(generate)
+	echo 'Setting password...'
+	curl -Ss -X POST \
+		-F "uid=${uid}" -F "key=${key}" \
+		-F "new1=${password}" -F "new2=${password}" \
+		'https://lwn.net/Login/DoSetPassword' \
+		>/dev/null
+	copy "${password}"
+	open 'https://lwn.net/Login/'
+}
+
 patreon() {
 	readonly patreonAPI='https://www.patreon.com/api'
 	echo 'Submitting form...'