File: bootcdflopcp

package info (click to toggle)
bootcd 3.10%2Bnmu1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 508 kB
  • ctags: 128
  • sloc: sh: 3,935; makefile: 117
file content (131 lines) | stat: -rwxr-xr-x 2,759 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh
# bootcdflopcp
# History 
#   28.07.2000 - Recognize empty files too.
#              - Do not depend on diff flag -N any longer.
#              - Ignore symbolic links to same target.
set -e
LANG=C

VERBOSE=""
FLOPPY=/dev/fd0
while [ "$*" ]; do

  if [ "$1" = "-v" ]; then
    VERBOSE="-v"
    shift
  elif [ "$1" = "-d" ]; then
    FLOPPY=$2
    shift 2
  elif [ "$*" ]; then
    echo "Usage: bootcdflopcp [-v] [-d <device>]"
    echo "  use man bootcdflopcp to get help" >&2
    echo "  device can be another device instead of /dev/floppy" >&2
    exit 1
  fi

done

TMP=/tmp/flopcp$$
MNTP=/mnt/floppy

mkdir -p $MNTP || exit 1
mount $FLOPPY $MNTP || exit 1
trap "umount $MNTP; rmdir $MNTP; rm -f $TMP" 0

touch $MNTP/remove $MNTP/change $MNTP/ignore $MNTP/execute
chmod 755 $MNTP/execute

IGNORE=""
CHANGE=""
REMOVE=""

# Search all Files that differ 
for i in etc home root
do
  diff --brief -r /$i.ro /$i 2>/dev/null | 
    # Files /etc.ro/hosts and /etc/hosts differ
    # Only in /etc.ro: resolv.conf

  sed "s| /$i.ro| /$i|g" |
    # Files /etc/hosts and /etc/hosts differ
    # Only in /etc: resolv.conf

  sed "s/Files .* and \(.*\) differ/\1/" |
  sed "s|Only in \(.*\): \(.*\)|\1/\2|"
    # /etc/hosts
    # /etc/resolv.conf
done |

# Ignore symbolic links that lead to the same file
while read f; do
  if [ -L $f ]; then 
    fro=`echo $f | sed "s|/\([^/]*\)/|/\1.ro/|"`
    if [ -L $fro ]; then 
      t=`/bin/ls -l $f | awk '{print $NF }'`
      tro=`/bin/ls -l $fro | awk '{print $NF }'`
      if [ "$t" = "$tro" ]; then
        [ "$VERBOSE" ] && echo "ignoring $f" >&2
        f=""
      fi
    fi
  fi
  [ "$f" ] && echo "$f"
done >$TMP

for f in `cat $TMP`; do
  if [ "`grep ^$f$ $MNTP/ignore`" ]; then
    IGNORE="$f $IGNORE"
    continue
  fi

  if [ -e "$f" ]; then
    if [ "`grep ^$f$ $MNTP/change`" ]; then
      CHANGE="$f $CHANGE"
      continue
    fi

    while :
    do
      echo "change $f (y/n)"
      read a
      if [ "$a" = "y" ]; then
        echo $f >> $MNTP/change
        CHANGE="$f $CHANGE"
        break
      elif [ "$a" = "n" ]; then
        echo $f >> $MNTP/ignore
        IGNORE="$f $IGNORE"
        break
      fi
    done
  else
    if [ "`grep ^$f$ $MNTP/remove`" ]; then
      REMOVE="$f $REMOVE"
      continue
    fi
    while :
    do
      echo "remove $f (y/n) "
      read a
      if [ "$a" = "y" ]; then
        echo $f >> $MNTP/remove
        REMOVE="$f $REMOVE"
        break
      elif [ "$a" = "n" ]; then
        echo $f >> $MNTP/ignore
        IGNORE="$f $IGNORE"
        break
      fi
    done
  fi
done

if [ "$VERBOSE" ]; then
  echo "Changing $CHANGE." >&2
  echo "Removing $REMOVE." >&2
  echo "Ignoring $IGNORE." >&2
fi

(cd /; tar cz -T $MNTP/change -f $MNTP/change.tgz)
exit 0