nixos-config/legacy/sync-script.nix

32 lines
744 B
Nix
Raw Normal View History

2023-05-04 20:59:26 +02:00
{ pkgs, ... }:
2023-05-04 19:35:15 +02:00
{
2023-05-04 20:59:26 +02:00
environment.systemPackages = [
2023-05-04 19:35:15 +02:00
(pkgs.writers.writeBashBin "torrent-sync" ''
2023-05-04 20:59:26 +02:00
set -e
set -x
2023-05-04 19:35:15 +02:00
2023-05-04 20:59:26 +02:00
file_folder=$( realpath "$1" )
folder=$( dirname "$file_folder" )
file=$( basename "$file_folder" )
2023-05-04 19:35:15 +02:00
2023-05-04 20:59:26 +02:00
pushd "$folder"
${pkgs.transmission}/bin/transmission-create \
-t udp://robi.private:6969/announce \
-o ~/last.torrent \
"$file"
popd
2023-05-04 19:35:15 +02:00
2023-05-04 20:59:26 +02:00
${pkgs.transmission}/bin/transmission-remote \
sync.chungus.private:80 \
-a ~/last.torrent \
--download-dir "$folder"
2023-05-04 19:35:15 +02:00
2023-05-04 20:59:26 +02:00
${pkgs.transmission}/bin/transmission-remote \
sync.robi.private:80 \
-a ~/last.torrent \
--download-dir "$folder"
2023-05-04 19:35:15 +02:00
'')
2023-05-04 20:59:26 +02:00
];
}