nix-setup/startsync.script.nix
2024-11-04 16:35:36 +01:00

27 lines
562 B
Nix

with import <nixpkgs> {};
pkgs.writeShellScriptBin "startsync" ''
#!/bin/sh
script="$0"
killall sshfs sftp
sleep 0.5
killall -9 sshfs sftp
sudo umount -l ~/sync
sleep 0.5
mkdir ~/broken
mv ~/sync/* ~/broken/
if [ "$1" = "stop" ] ; then exit ; fi
sshfs -p 23 root@tudbut.de:sync ~/sync
while ! ls ~/sync/Passwords.kdbx ; do sleep 0.2 ; done
while true ; do
(cat ~/sync/test > /dev/null ; touch ~/.syncfs_ok) &
sleep 7
if ! [ -e ~/.syncfs_ok ] ; then
"$script" stop
exit
fi
rm ~/.syncfs_ok
done & disown
exec keepassxc
''