--- /dev/null
+#!/bin/sh
+# Copyright (c) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+. /etc/environment
+
+PERM_LINK="https\:\/\/myaccount\.google\.com\/permissions"
+
+with_hyperlink() {
+ echo "${1}" | sed s/${PERM_LINK}/"<a href=\"${PERM_LINK}\">link<\/a>"/
+}
+
+python3 -u -m gdrive_knife auth \
+ --credentials ${gdrive_credentials} \
+ --token ${gdrive_auth_token} \
+ --on_success https://drive.${private_domain} \
+ --on_token https://drive.${private_domain}/auth \
+ --port 3030 \
+ | while read -r line
+ do
+ case "${line}" in
+ *"Reset permissions"*)
+ echo "HTTP/1.1 403 Forbidden"
+ echo "Content-Type: text/html"
+ echo ""
+ echo "<body>$(with_hyperlink "${line}")</body>"
+ exit 1
+ ;;
+ *"Authentication URL"*)
+ echo "HTTP/1.1 307 Temporary Redirect"
+ echo "Location: $(echo ${line} | sed 's/^.*\s//')"
+ echo ""
+ ;;
+ esac
+ done