File: savemode.sh

package info (click to toggle)
fakechroot 2.19-3.2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,124 kB
  • sloc: ansic: 6,875; sh: 5,995; makefile: 348; perl: 169; java: 5
file content (21 lines) | stat: -rwxr-xr-x 661 bytes parent folder | download | duplicates (8)
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