[bin] Rewrite drop in plain bash
Ruby no likey ed25519 keys. :-(
This commit is contained in:
parent
e557543c4f
commit
2d027bf66f
|
@ -1,21 +1,17 @@
|
||||||
#! /usr/bin/env nix-shell
|
#!/usr/bin/env bash
|
||||||
#! nix-shell -i ruby -p ruby -p rubyPackages.net-scp
|
|
||||||
|
|
||||||
require 'open3'
|
|
||||||
require 'pathname'
|
|
||||||
require 'securerandom'
|
|
||||||
require 'net/scp'
|
|
||||||
|
|
||||||
file = Pathname.new(ARGV[0])
|
file="${1}"
|
||||||
new_name = SecureRandom.hex(12) + File.extname(file)
|
filename=$(basename -- "$file")
|
||||||
abort "Och komm." unless file.exist? and file.readable?
|
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 "${file}" "drop.bascht.space:/home/bascht/drop/${new_name}"
|
||||||
scp.upload(file.expand_path.to_s, "/home/bascht/drop/#{new_name}")
|
wl-copy "${url}"
|
||||||
end
|
notify-send -t 1000 "Uploaded successfully" "<a href=\'${url}\'>drop.bascht.space</a>"
|
||||||
|
|
||||||
system "wl-copy #{url}"
|
|
||||||
|
|
||||||
system("notify-send -t 1000 'Uploaded successfully' '<a href=\'#{url}\'>drop.bascht.space</a>'")
|
|
||||||
|
|
Loading…
Reference in New Issue