state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
- Copyright (C) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+ Copyright (C) 2023-2024 Jakub Czajka <jakub@ekhem.eu.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
- gdrive_proxy Copyright (C) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+ gdrive_proxy Copyright (C) 2023-2024 Jakub Czajka <jakub@ekhem.eu.org>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
--- /dev/null
+#!/bin/sh
+# Copyright (c) 2024 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+. /etc/environment
+
+FILE_TO_AMEND=$(sed --expression='/Content-Disposition.*filename/!d' \
+ --expression='s/^.*filename=\"// ; s/\".*$//' "${PATH_TO_FILE}")
+
+# See upload.sh.
+NAME_ON_DRIVE=$(sed --silent 'x;$p' "${PATH_TO_FILE}" | tr --delete '\r\n')
+sed --in-place --silent --expression='1,4d' \
+ --expression=':a;N;4,9ba;P;D' ${PATH_TO_FILE}
+
+# See download.sh.
+FULL_NAME=$(echo ${NAME_ON_DRIVE} | sed 's/%2F/\//g; s/%0D%0A//g')
+BASE_NAME=$(basename "${FULL_NAME}")
+
+# Clear /tmp for download.
+if [ -e "/tmp/${BASE_NAME}" ]
+then
+ rm -rf "/tmp/${BASE_NAME}"
+fi
+
+echo "HTTP/1.1 200 OK"
+echo "Content-Type: text/html"
+echo "
+<!DOCTYPE html>
+<html>
+<meta name='viewport' content='width=device-width'>
+<head>
+ <style>
+ body {
+ white-space: pre-wrap;
+ }
+ </style>
+</head>
+<body>"
+echo "Downloading ${FULL_NAME}"
+python3 -u -m gdrive_knife 2>&1 download --token ${gdrive_auth_token} \
+ --key ${gdrive_encryption_key} ${FULL_NAME} /tmp
+
+if [ ! -d "/tmp/${BASE_NAME}" ]
+then
+ echo "${FULL_NAME} is not a directory. Not amending."
+else
+ echo "Amending ${FILE_TO_AMEND}"
+ mv ${PATH_TO_FILE} /tmp/${BASE_NAME}/${FILE_TO_AMEND}
+
+ echo "Uploading ${FULL_NAME}"
+ python3 -u -m gdrive_knife 2>&1 upload --token ${gdrive_auth_token} \
+ --key ${gdrive_encryption_key} /tmp/${BASE_NAME} ${FULL_NAME}
+fi
+
+echo "\
+</body>
+</html>"
-# Copyright (c) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+# Copyright (c) 2023-2024 Jakub Czajka <jakub@ekhem.eu.org>
# License: GPL-3.0 or later.
server {
fastcgi_param SCRIPT_FILENAME ${dollar}document_root/upload.sh;
}
+ location = /amend {
+ include fastcgi_params;
+ fastcgi_pass unix:/var/run/fcgiwrap.socket;
+
+ client_body_in_file_only clean;
+ client_body_temp_path /tmp;
+
+ fastcgi_pass_request_body off;
+ fastcgi_pass_request_headers off;
+
+ fastcgi_buffering off;
+ fastcgi_param NO_BUFFERING "";
+
+ fastcgi_param PATH_TO_FILE ${dollar}request_body_file;
+ fastcgi_param SCRIPT_FILENAME ${dollar}document_root/amend.sh;
+ }
+
location = / {
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
#!/bin/sh
-# Copyright (c) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+# Copyright (c) 2023-2024 Jakub Czajka <jakub@ekhem.eu.org>
# License: GPL-3.0 or later.
. /etc/environment
</fieldset>
</form>
+ <form action='/amend' method='post' enctype='multipart/form-data'>
+ <fieldset>
+ <legend>Amend</legend>
+ <input type='file' name='file' required />
+ <select id='name' name='name'>
+ $(format_files "<option value='{}'>{}</option>")
+ </select>
+ <button type='submit'>Amend</button>
+ </fieldset>
+ </form>
+
<form action='/download'>
<fieldset>
<legend>Download</legend>