--- /dev/null
+#!/bin/sh
+# Copyright (c) 2024 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+. /etc/environment
+
+format_accounts() {
+ echo ${gdrive_accounts} \
+ | xargs --replace={} \
+ --delimiter=" " echo "<option value='{}'>{}</option>"
+}
+
+PAGE="
+<!DOCTYPE html>
+<html>
+<head>
+ <title>GdriveProxy</title>
+ <meta name='viewport' content='width=device-width'>
+ <style>
+ body {
+ background-color: #7fa99b;
+ }
+ form {
+ width: min(400px, 100%);
+ }
+ fieldset {
+ background-color: #f1d18a;
+ display: flex;
+ flex-direction: column;
+ row-gap: 10px;
+ }
+ </style>
+</head>
+<body>
+ <form action='/list'>
+ <fieldset>
+ <legend>Account</legend>
+ <select id='account' name='account'>
+ $(format_accounts)
+ </select>
+ <button type='submit'>Select</button>
+ </fieldset>
+ </form>
+</body>
+</html>"
+
+echo "HTTP/1.1 200 OK"
+echo "Content-type: text/html"
+echo "${PAGE}" | sed 's/^[ \t]*//g'
python3 -u -m gdrive_knife auth \
--credentials ${gdrive_credentials} \
- --token ${gdrive_auth_token} \
+ --token ${AUTH_TOKEN} \
--on_success https://drive.${private_domain} \
--on_token https://drive.${private_domain}/auth \
--port 3030 \
proxy_pass http://localhost:3030;
}
+ location ~ ^/list(.*) {
+ include fastcgi_params;
+ fastcgi_pass unix:/var/run/fcgiwrap.socket;
+
+ fastcgi_keep_conn on;
+ fastcgi_read_timeout 3s;
+
+ fastcgi_buffering off;
+ fastcgi_param NO_BUFFERING "";
+
+ fastcgi_param ACCOUNT ${dollar}arg_account;
+ fastcgi_param SCRIPT_FILENAME ${dollar}document_root/gdrive_proxy.sh;
+ }
+
location = /delete {
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
- fastcgi_keep_conn on;
- fastcgi_read_timeout 3s;
-
- fastcgi_buffering off;
- fastcgi_param NO_BUFFERING "";
-
- fastcgi_param SCRIPT_FILENAME ${dollar}document_root/gdrive_proxy.sh;
+ fastcgi_param SCRIPT_FILENAME ${dollar}document_root/account.sh;
}
}
# Kill authentication server if already present.
[ ! -z $(pgrep --full ".*gdrive_knife.*") ] && pkill --full ".*gdrive_knife.*"
+AUTH_TOKEN="${prod_dir}/${gdrive_proxy}/${ACCOUNT}.json"
+
. ./auth.sh || exit 0
-FILES=$(python3 -u -m gdrive_knife 2>&1 list --token ${gdrive_auth_token})
+FILES=$(python3 -u -m gdrive_knife 2>&1 list --token ${AUTH_TOKEN})
format_files() {
echo ${FILES} | xargs --replace={} --delimiter=" " echo "${1}"