Update share-sync
756067900269b55fe928b7f6c31c26bacbdeedc2
1 parent
1e5101a2
bin/share-sync
+22 -0
| 1 | 1 | #!/bin/sh |
|
| 2 | + | # pacman -S inotify-tools openssh rsync |
|
| 3 | + | ||
| 4 | + | set -euf -o pipefail |
|
| 2 | 5 | ||
| 3 | 6 | dir=$HOME/share/ |
|
| 4 | 7 | user=$(whoami) |
|
| 5 | 8 | ||
| 9 | + | if [ ! -d "$dir" ]; then |
|
| 10 | + | echo "First-time sync.." |
|
| 11 | + | ||
| 12 | + | cd $HOME |
|
| 13 | + | ||
| 14 | + | mkdir $dir |
|
| 15 | + | rsync -avz $user@box:share $HOME |
|
| 16 | + | ||
| 17 | + | ln -sf share/txt ~/txt |
|
| 18 | + | ln -sf share/notes ~/notes |
|
| 19 | + | ln -sf share/crypto ~/crypto |
|
| 20 | + | ln -sf share/papers ~/papers |
|
| 21 | + | ln -sf share/docs ~/docs |
|
| 22 | + | ||
| 23 | + | echo "Synced." |
|
| 24 | + | ||
| 25 | + | exit 0 |
|
| 26 | + | fi |
|
| 27 | + | ||
| 6 | 28 | echo "Backup service started.." | systemd-cat -p info |
|
| 7 | 29 | ||
| 8 | 30 | while inotifywait -qqr \ |
|
| 9 | 31 | -e modify -e moved_to -e moved_from -e create -e delete "$dir"; |
|
| 10 | 32 | do |