2021-06-09 09:29:59 +02:00
|
|
|
#! /usr/bin/env nix-shell
|
|
|
|
#! nix-shell -i ruby -p ruby -p rubyPackages.net-scp
|
2017-01-19 21:03:21 +01:00
|
|
|
|
|
|
|
require 'open3'
|
2017-06-28 09:51:59 +02:00
|
|
|
require 'pathname'
|
|
|
|
require 'securerandom'
|
|
|
|
require 'net/scp'
|
2017-01-19 21:03:21 +01:00
|
|
|
|
|
|
|
file = Pathname.new(ARGV[0])
|
2020-02-22 17:55:11 +01:00
|
|
|
new_name = SecureRandom.hex(12) + File.extname(file)
|
2017-01-19 21:03:21 +01:00
|
|
|
abort "Och komm." unless file.exist? and file.readable?
|
|
|
|
|
2020-10-07 09:03:49 +02:00
|
|
|
url = "https://drop.bascht.space/#{new_name}"
|
2017-01-19 21:03:21 +01:00
|
|
|
|
2017-06-28 09:51:59 +02:00
|
|
|
Net::SCP.start("drop.bascht.space", "bascht") do |scp|
|
|
|
|
scp.upload(file.expand_path.to_s, "/home/bascht/drop/#{new_name}")
|
|
|
|
end
|
2017-01-19 21:03:21 +01:00
|
|
|
|
2020-02-22 18:51:41 +01:00
|
|
|
system "wl-copy #{url}"
|
2019-06-05 13:22:08 +02:00
|
|
|
|
2020-06-10 13:25:33 +02:00
|
|
|
system("notify-send -t 1000 'Uploaded successfully' '<a href=\'#{url}\'>drop.bascht.space</a>'")
|