-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanrsd
More file actions
executable file
·67 lines (47 loc) · 1.56 KB
/
Copy pathcleanrsd
File metadata and controls
executable file
·67 lines (47 loc) · 1.56 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
#! /bin/sh
# CleanRSD
# (C) 2017-2018 Jérémie Roquet <jroquet@arkanosis.net>
# Released under the ISC license
# https://github.com/Arkanosis/CleanRSD/
VERSION='v0.1.0-dev'
usage() {
echo 'Usage: cleanrsd <mount_point>'
}
if [ $# -lt 1 ] || [ "x$1" = 'x-h' ] || [ "x$1" = 'x--help' ]; then
usage
exit
fi
if [ "x$1" = "x--version" ]; then
echo "cleanrsd $VERSION"
exit
fi
if [ -z "$1" ] || ! [ -d "$1" ] || ! [ -w "$1" ]; then
echo "'$1' is not a writable directory" >&2
exit 1
fi
# English
cat > "$1/IF YOU FIND THIS.TXT" <<EOF
If you find this removable storage device, please contact its owner:
Jérémie Roquet (Arkanosis)
jroquet@arkanosis.net
+33 6 33 07 69 95
EOF
# French
cat > "$1/SI VOUS TROUVEZ CECI.TXT" <<EOF
Si vous trouvez ce périphérique de stockage amovible, merci de contacter son propriétaire :
Jérémie Roquet (Arkanosis)
jroquet@arkanosis.net
+33 6 33 07 69 95
EOF
# Apple file system events daemon
rm -rf "$1/.fseventsd" && mkdir "$1/.fseventsd" && touch "$1/.fseventsd/no_log"
# Apple Spotlight
rm -rf "$1/.Spotlight-V100" && touch "$1/.metadata_never_index"
# Apple Mac OS X
rm -rf "$1/.Trashes" "$1/._.Trashes" && touch "$1/.Trashes" "$1/._.Trashes"
# Apple Finder
find "$1" -type d \( -name '.DS_Store' -o -name '._.DS_Store' \) -exec echo -- rm -rf {} \;
# Microsoft Windows Explorer
find "$1" -type f \( -name 'Thumbs.db' -o -name 'desktop.ini' \) -exec rm -f {} \;
find "$1" -type d \( -name 'System Volume Information' -o -name '$RECYCLE.BIN' \) -exec rm -rf {} \;
echo "Device mounted at '$1' has been set up."