diff options
author | Malte Voos <git@mal.tc> | 2024-12-19 21:57:44 +0100 |
---|---|---|
committer | Malte Voos <git@mal.tc> | 2024-12-19 21:58:25 +0100 |
commit | 806dc1ed43be0e638fc1d60881afdae812d0e4e6 (patch) | |
tree | 5dc850e823e1ebf111fd7c9600361bdcab88f70e /client.nix | |
parent | df4d1f249b631d8dc19db846cdb9deb4e0d01f3b (diff) | |
download | reMder-806dc1ed43be0e638fc1d60881afdae812d0e4e6.tar.gz reMder-806dc1ed43be0e638fc1d60881afdae812d0e4e6.zip |
switch to rmpp image
Diffstat (limited to 'client.nix')
-rw-r--r-- | client.nix | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/client.nix b/client.nix new file mode 100644 index 0000000..67c083c --- /dev/null +++ b/client.nix @@ -0,0 +1,33 @@ +{ writeShellApplication, curl, openssh, sshpass, rsync, sshPassword, sshPort +, httpPort }: + +writeShellApplication { + name = "reMder-client"; + + runtimeInputs = [ curl openssh sshpass rsync ]; + + text = let + ssh = + "sshpass -p ${sshPassword} ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p ${ + toString sshPort + }"; + guest = "root@127.0.0.1"; + documentDir = "/home/root/.local/share/remarkable/xochitl"; + in '' + in="$1" + out="$2" + + in_basename="$(basename "$in")" + + ${ssh} ${guest} rm -rf ${documentDir} + ${ssh} ${guest} mkdir ${documentDir} + + 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" + ''; +} |