From 2d027bf66fd4371671c7c3a1d97a1b6b89a15ec0 Mon Sep 17 00:00:00 2001 From: Sebastian Schulze Date: Thu, 29 Jul 2021 12:39:01 +0200 Subject: [PATCH] [bin] Rewrite drop in plain bash Ruby no likey ed25519 keys. :-( --- bin/executable_drop | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/bin/executable_drop b/bin/executable_drop index eaae63a..3839668 100644 --- a/bin/executable_drop +++ b/bin/executable_drop @@ -1,21 +1,17 @@ -#! /usr/bin/env nix-shell -#! nix-shell -i ruby -p ruby -p rubyPackages.net-scp +#!/usr/bin/env bash -require 'open3' -require 'pathname' -require 'securerandom' -require 'net/scp' -file = Pathname.new(ARGV[0]) -new_name = SecureRandom.hex(12) + File.extname(file) -abort "Och komm." unless file.exist? and file.readable? +file="${1}" +filename=$(basename -- "$file") +extension="${filename##*.}" +new_name="$(openssl rand -hex 12).${extension}" +url="https://drop.bascht.space/${new_name}" -url = "https://drop.bascht.space/#{new_name}" +if [[ ! -f "${file}" ]]; then + echo "File ${file} not readable. Aborting." + exit 1 +fi -Net::SCP.start("drop.bascht.space", "bascht") do |scp| - scp.upload(file.expand_path.to_s, "/home/bascht/drop/#{new_name}") -end - -system "wl-copy #{url}" - -system("notify-send -t 1000 'Uploaded successfully' 'drop.bascht.space'") +scp "${file}" "drop.bascht.space:/home/bascht/drop/${new_name}" +wl-copy "${url}" +notify-send -t 1000 "Uploaded successfully" "drop.bascht.space"