about summary refs log tree commit diff
path: root/client.nix
diff options
context:
space:
mode:
Diffstat (limited to 'client.nix')
-rw-r--r--client.nix21
1 files changed, 14 insertions, 7 deletions
diff --git a/client.nix b/client.nix
index ad58693..6563533 100644
--- a/client.nix
+++ b/client.nix
@@ -21,23 +21,30 @@ writeShellApplication {
 
   text =
     let
-      ssh = "sshpass -p ${sshPassword} ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p ${toString sshPort}";
+      ssh = "sshpass -p ${sshPassword} ssh -q -F none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p ${toString sshPort}";
       guest = "root@127.0.0.1";
       documentDir = "/home/root/.local/share/remarkable/xochitl";
+      baseUrl = "http://127.0.0.1:${toString httpPort}";
     in
     ''
       in="$1"
       out="$2"
 
-      in_basename="$(basename "$in")"
+      ${ssh} ${guest} << EOF
+        rm -rf ${documentDir}
+        mkdir ${documentDir}
+      EOF
 
-      ${ssh} ${guest} rm -rf ${documentDir}
-      ${ssh} ${guest} mkdir ${documentDir}
+      curl \
+        '${baseUrl}/upload' \
+        -H 'Origin: http://10.11.99.1' \
+        -H 'Accept: */*' \
+        -H 'Referer: http://10.11.99.1/' \
+        -H 'Connection: keep-alive' \
+        -F "file=@\"$in\";filename=to-render.rmdoc;type=application/octet-stream"
 
-      rsync --rsh="${ssh}" "$in" ${guest}:${documentDir}
-      ${ssh} ${guest} "unzip '${documentDir}/$in_basename' -d ${documentDir}"
       doc_id="$(${ssh} ${guest} find ${documentDir} -name '\*.metadata' -exec basename {} .metadata '\;')"
 
-      curl -f -o "$out" "http://127.0.0.1:${toString httpPort}/download/$doc_id/placeholder"
+      curl -f -o "$out" "${baseUrl}/download/$doc_id/placeholder"
     '';
 }