1 |
jonen |
1.1 |
################################################## |
2 |
jonen |
1.2 |
# $Id: mini-howto_trashcan-under-Linux_libtrash.pod,v 1.1 2003/01/25 08:43:21 jonen Exp $ |
3 |
jonen |
1.1 |
# |
4 |
|
|
################################################## |
5 |
|
|
# |
6 |
jonen |
1.2 |
# $Log: mini-howto_trashcan-under-Linux_libtrash.pod,v $ |
7 |
|
|
# Revision 1.1 2003/01/25 08:43:21 jonen |
8 |
|
|
# + moved/convert to perlpod format |
9 |
|
|
# |
10 |
jonen |
1.1 |
# |
11 |
|
|
# |
12 |
|
|
################################################## |
13 |
|
|
|
14 |
|
|
=pod |
15 |
|
|
|
16 |
|
|
|
17 |
|
|
=head2 Implements a "trash can" under GNU/Linux with 'libtrash' |
18 |
|
|
|
19 |
|
|
|
20 |
|
|
=head3 Description |
21 |
|
|
|
22 |
|
|
All stuff here is mainly copied from the libtrash doc. |
23 |
|
|
|
24 |
|
|
libtrash is a shared library which, when preloaded, implements a trash can under GNU/Linux. |
25 |
|
|
This way, your mistakes (at least those of the "rm -rf dir /" class :-)) will no longer cause |
26 |
|
|
the loss of a week's work or your system's binaries. |
27 |
|
|
|
28 |
|
|
|
29 |
|
|
=head4 install libtrash |
30 |
|
|
|
31 |
|
|
apt-get install libtrash |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
or for those of you that aren't running Debian GNU/Linux: |
35 |
|
|
|
36 |
|
|
wget http://www.m-arriaga.net/software/libtrash/libtrash-latest.tgz |
37 |
|
|
tar xzf libtrash-latest.tgz |
38 |
|
|
cd libtrash-1.7/ |
39 |
|
|
|
40 |
|
|
edit Makefile for common settings |
41 |
|
|
|
42 |
|
|
make install (as root) |
43 |
|
|
|
44 |
|
|
|
45 |
|
|
=head4 test |
46 |
|
|
|
47 |
|
|
export LD_PRELOAD=/usr/lib/libtrash/libtrash.so |
48 |
|
|
rm -r <some_test_file> |
49 |
|
|
|
50 |
|
|
|
51 |
|
|
=head4 enable libtrash at login |
52 |
|
|
|
53 |
|
|
Include this in your ~/.bash_profile(or for system-wide usage in /etc/profile) |
54 |
|
|
to enable libtrash every time you log in (or otherwise start a login shell) |
55 |
|
|
|
56 |
|
|
#-------------- snip --------------------------- |
57 |
|
|
LIBTRASH=/usr/lib/libtrash/libtrash.so |
58 |
|
|
|
59 |
|
|
LIBTRASH_dest=$LIBTRASH |
60 |
|
|
if test -L $LIBTRASH ; then |
61 |
|
|
LIBTRASH_dest="$(dirname $LIBTRASH)/$(ls -l "$LIBTRASH" | \ |
62 |
|
|
sed -e 's/^.\+ -> //')" |
63 |
|
|
fi |
64 |
|
|
|
65 |
|
|
if test x${LD_PRELOAD+set} = x -a -f "$LIBTRASH_dest" ; then |
66 |
|
|
LD_PRELOAD="$LIBTRASH" |
67 |
|
|
export LD_PRELOAD |
68 |
|
|
if test x$0 = x-bash ; then |
69 |
|
|
exec bash ${1+"$@"} |
70 |
|
|
else |
71 |
|
|
exec $0 ${1+"$@"} |
72 |
|
|
fi |
73 |
|
|
fi |
74 |
|
|
#-------------- end snip --------------------------- |
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
=head4 create user specify config |
79 |
|
|
|
80 |
|
|
- READ /etc/libtrash.conf !! |
81 |
|
|
- overwrite default values by setting up a ~/.libtrash for each user: |
82 |
|
|
|
83 |
|
|
# sample ~/.libtrash: |
84 |
|
|
#-------------- snip --------------------------- |
85 |
|
|
GLOBAL_PROTECTION = YES |
86 |
|
|
INTERCEPT_FOPEN = YES |
87 |
|
|
INTERCEPT_FREOPEN = YES |
88 |
|
|
INTERCEPT_OPEN = YES |
89 |
|
|
IGNORE_HIDDEN = NO |
90 |
|
|
IGNORE_EXTENSIONS= o;exe |
91 |
|
|
#-------------- end snip --------------------------- |
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
=head4 use 'cleanTrash' for cleaning Trash via cronjob |
96 |
|
|
|
97 |
|
|
- gunzip & copy '/usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz' |
98 |
|
|
to '/usr/local/bin/cleanTrash' e.g: |
99 |
|
|
|
100 |
|
|
'zcat /usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz > /usr/local/bin/cleanTrash' |
101 |
|
|
|
102 |
|
|
|
103 |
|
|
- edit '/usr/local/bin/cleanTrash' for local configuration |
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
=head5 insert cronjob for root |
108 |
|
|
|
109 |
|
|
- crontab -e (as root) |
110 |
|
|
- insert: 3,13,23,33,43,53 * * * * root /usr/local/bin/cleanTrash |
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
=head3 Important Notes |
115 |
|
|
|
116 |
|
|
|
117 |
|
|
=over |
118 |
|
|
|
119 |
|
|
=item Gerneral |
120 |
|
|
|
121 |
|
|
READ /etc/libtrash.conf !! |
122 |
|
|
If libtrash.so is global enabled via /etc/profile, a DEFAULT or WRONG ~/.libtrash configuration would |
123 |
|
|
causes gdm, root writes(if root writes are also protected by lintrash), kde etc. stops working !! |
124 |
|
|
|
125 |
|
|
solution to disable libtrash in enviroment immediately: |
126 |
|
|
- export LD_PRELOAD="" |
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
=item XTerm |
131 |
|
|
|
132 |
jonen |
1.2 |
to get a login shell, start XTerm with '-ls' (~/.profile will not be executed if not) |
133 |
jonen |
1.1 |
|
134 |
|
|
|
135 |
|
|
=back |
136 |
|
|
|
137 |
|
|
|
138 |
|
|
=head3 Resources |
139 |
|
|
|
140 |
|
|
=over |
141 |
|
|
|
142 |
|
|
=item Libtrash - Implements a "trash can" under GNU/Linux |
143 |
|
|
|
144 |
|
|
http://www.m-arriaga.net/software/libtrash/ |
145 |
|
|
|
146 |
|
|
=back |
147 |
|
|
|
148 |
|
|
|
149 |
|
|
=head3 Authors |
150 |
|
|
|
151 |
|
|
Sebastian Utz seut@tunemedia.de |
152 |
|
|
|
153 |
|
|
|
154 |
|
|
=head3 Last changes |
155 |
|
|
|
156 |
|
|
Revision 1.1 2003/01/24 17:47:49: |
157 |
|
|
+ create new |
158 |
|
|
|
159 |
|
|
|
160 |
|
|
=cut |
161 |
|
|
|