1 |
jonen |
1.1 |
################################################## |
2 |
|
|
# $Id$ |
3 |
|
|
# |
4 |
|
|
################################################## |
5 |
|
|
# |
6 |
|
|
# libtrash.so / Implements a Trashcan for linux shell and progs |
7 |
|
|
# - short Debian Installation Guide - |
8 |
|
|
# |
9 |
|
|
################################################## |
10 |
|
|
# |
11 |
|
|
# $Log$ |
12 |
|
|
# |
13 |
|
|
################################################## |
14 |
|
|
|
15 |
|
|
|
16 |
|
|
##################################### |
17 |
|
|
# notes: |
18 |
|
|
# |
19 |
|
|
libtrash is a shared library which, when preloaded, implements a trash can under GNU/Linux. |
20 |
|
|
This way, your mistakes (at least those of the "rm -rf dir /" class :-)) will no longer cause |
21 |
|
|
the loss of a week's work or your system's binaries. |
22 |
|
|
|
23 |
|
|
##################################### |
24 |
|
|
# install libtrash: |
25 |
|
|
# |
26 |
|
|
apt-get install libtrash |
27 |
|
|
|
28 |
|
|
##################################### |
29 |
|
|
# test: |
30 |
|
|
# |
31 |
|
|
export LD_PRELOAD=/usr/lib/libtrash/libtrash.so |
32 |
|
|
rm -r <some_test_file> |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
##################################### |
36 |
|
|
# enable libtrash at login: |
37 |
|
|
# |
38 |
|
|
Include this in your ~/.bash_profile(or for system-wide usage in /etc/profile) |
39 |
|
|
to enable libtrash every time you log in (or otherwise start a login shell) |
40 |
|
|
|
41 |
|
|
#-------------- snip --------------------------- |
42 |
|
|
LIBTRASH=/usr/lib/libtrash/libtrash.so |
43 |
|
|
|
44 |
|
|
LIBTRASH_dest=$LIBTRASH |
45 |
|
|
if test -L $LIBTRASH ; then |
46 |
|
|
LIBTRASH_dest="$(dirname $LIBTRASH)/$(ls -l "$LIBTRASH" | \ |
47 |
|
|
sed -e 's/^.\+ -> //')" |
48 |
|
|
fi |
49 |
|
|
|
50 |
|
|
if test x${LD_PRELOAD+set} = x -a -f "$LIBTRASH_dest" ; then |
51 |
|
|
LD_PRELOAD="$LIBTRASH" |
52 |
|
|
export LD_PRELOAD |
53 |
|
|
if test x$0 = x-bash ; then |
54 |
|
|
exec bash ${1+"$@"} |
55 |
|
|
else |
56 |
|
|
exec $0 ${1+"$@"} |
57 |
|
|
fi |
58 |
|
|
fi |
59 |
|
|
#-------------- end snip --------------------------- |
60 |
|
|
|
61 |
|
|
|
62 |
|
|
##################################### |
63 |
|
|
# create user specify config |
64 |
|
|
# |
65 |
|
|
- READ /etc/libtrash.conf !! |
66 |
|
|
- overwrite default values by setting up a ~/.libtrash for each user: |
67 |
|
|
|
68 |
|
|
# sample ~/.libtrash: |
69 |
|
|
#-------------- snip --------------------------- |
70 |
|
|
GLOBAL_PROTECTION = YES |
71 |
|
|
INTERCEPT_FOPEN = YES |
72 |
|
|
INTERCEPT_FREOPEN = YES |
73 |
|
|
INTERCEPT_OPEN = YES |
74 |
|
|
IGNORE_HIDDEN = NO |
75 |
|
|
IGNORE_EXTENSIONS= o;exe |
76 |
|
|
#-------------- end snip --------------------------- |
77 |
|
|
|
78 |
|
|
|
79 |
|
|
##################################### |
80 |
|
|
# use 'cleanTrash' for cleaning Trash via cronjob |
81 |
|
|
# |
82 |
|
|
- gunzip & copy '/usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz' |
83 |
|
|
to '/usr/local/bin/cleanTrash' e.g: |
84 |
|
|
|
85 |
|
|
'zcat /usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz > /usr/local/bin/cleanTrash' |
86 |
|
|
|
87 |
|
|
- edit '/usr/local/bin/cleanTrash' for local configuration |
88 |
|
|
|
89 |
|
|
# insert cronjob for root: |
90 |
|
|
- crontab -e (as root) |
91 |
|
|
- insert: 3,13,23,33,43,53 * * * * root /usr/local/bin/cleanTrash |
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
##################################### |
96 |
|
|
# Additional Notes |
97 |
|
|
# |
98 |
|
|
|
99 |
|
|
# XTerm |
100 |
|
|
to get a login shell, start XTerm with '-ls' (~/.profile will not be execute if not) |