Added transfer script, dsiabled sleep for server

This commit is contained in:
Jurn Wubben 2025-03-28 08:56:56 +01:00
parent 672d5d5405
commit 679be52764
4 changed files with 49 additions and 1 deletions

View file

@ -7,5 +7,6 @@
./starship.nix
./yazi.nix
./zoxide.nix
./transfer.nix
];
}

37
home/shell/transfer.nix Normal file
View file

@ -0,0 +1,37 @@
{
pkgs,
osConfig,
...
}: {
home.packages = [
(pkgs.writeShellScriptBin "transfer" ''
PASSWORD=$(sed 's/.*="\(.*\)"/\1/' ${osConfig.age.secrets.transferSh.path})
if [ -z "$PASSWORD" ]; then
echo "Error: Password not found."
return 1
fi
file_path="$1"
if [ -z "$file_path" ]; then
echo "Usage: transfer <file>"
return 1
fi
response=$(curl -sD - --user "jsw:$PASSWORD" --progress-bar --upload-file "$file_path" "https://share.jsw.tf/$(basename "$file_path")")
if [ $? -eq 0 ]; then
DELETE=$(echo "$response" | grep x-url-delete | sed "s/.*\///")
URL=$(echo "$response" | tail -n1)
echo "Delete code: $DELETE"
echo "URL: $URL"
else
echo "Upload failed."
return 1
fi
echo
'')
];
}