forked from andrewferrier/misc-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow-dropbox-conflicts
executable file
·55 lines (51 loc) · 1.49 KB
/
show-dropbox-conflicts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
#
# This script will show you all the filenames within a Dropbox directory tree
# that are conflicted (i.e. that have unresolved changes with the same file
# from another machine). You can use it by passing in the name of the Dropbox
# root:
#
# show-dropbox-conflicts ~/Dropbox/
#
# If you also have a portion of the tree which is encrypted using encfs,
# passing the -d option in addition will instead pass the filenames to
# encfsctl. You can enter the encfs password and the conflicted filenames will
# be decrypted to their plaintext versions:
#
# show-dropbox-conflicts -d ~/Dropbox/.encfs-subset/
#
# The first usage is non-interactive and is therefore suitable for running
# from a regular cron job to ensure conflicts aren't building up. The second
# prompts for the encfs password.
DECODE=false
while getopts ":d" opt; do
case $opt in
d)
DECODE=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
shift $(($OPTIND - 1))
if $DECODE; then
(cd $1 && find .) | \
grep -i -E "conflicted|konflikt" | \
grep -v .dropbox.cache | \
cut -f 1 -d ' ' | \
while read FILE; do
echo -n $FILE
echo -n " => "
encfsctl decode --extpass=./pass.sh $1 "$FILE"
done
else
(cd $1 && find .) | \
grep -i -E "conflicted|konflikt" | \
grep -v .dropbox.cache
exit 0
fi