startsync: auto unmount when not ok

This commit is contained in:
Daniella / Tove 2024-10-28 22:02:45 +01:00
parent 38c61b0740
commit 19ab3c5385
Signed by: TudbuT
GPG key ID: B3CF345217F202D3

View file

@ -2,13 +2,24 @@ 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
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
(ls ~/sync ; echo -n yes > ~/.syncfs_ok) &
sleep 5
if ! [ -e ~/.syncfs_ok ] ; then
"$script" stop
exit
fi
rm ~/.syncfs_ok
done & disown
exec keepassxc
''