1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#!/bin/sh
# This script saves uids and gids of files to savemode.dat? files
# which can be restored further with restoremode.sh script
#
# Only files with uid and gid different than current are saved.
#
# It should be started with root privileges or fakeroot command.
test -f savemode.dat1 && mv -f savemode.dat1 savemode.dat1~
test -f savemode.dat2 && mv -f savemode.dat2 savemode.dat2~
uid=`id -u`
gid=`id -g`
LANG=C find . \( -type b -o -type c -o -type p -o -type s \) \
| tar czPf savemode.dat1 -T-
LANG=C find . \( -type f -o -type d -o -type l \) \
-a \( ! -uid $uid -o ! -gid $gid \) -printf "%U %G %m %p\n" \
| gzip -9 > savemode.dat2
|