3
# ecryptfs-rewrite-file
4
# Copyright (C) 2008 Canonical Ltd.
6
# Authors: Dustin Kirkland <kirkland@canonical.com>
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, version 2 of the License.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
26
[ "$i" = "." ] && continue
28
echo -n "INFO: Rewriting [$j/$#] [$i] ... "
30
if [ -d "$i" -a ! -h "$i" ]; then
31
# A directory, re-encrypt the filename
32
temp1=`mktemp -d "$i".XXXXXXXXXX` || {
33
error "Could not create tempdir"
36
mv -f -T "$i" "$temp1" || {
37
error "Could not rename [$i] to [$temp1]"
41
mv -f "$temp1" "$i" || {
42
error "Could not rename [$temp1] to [$i]"
45
# A file or symlink, re-encrypt the contents
46
temp1=`mktemp "$i".XXXXXXXXXX` || {
47
error "Could not create tempfile"
50
cp -a "$i" "$temp1" || {
51
error "Could not copy [$i] to [$temp1]"
55
mv -f "$temp1" "$i" || {
56
error "Could not rename [$temp1] to [$i]"