summaryrefslogtreecommitdiffstats
path: root/infest/bin/make-patch
blob: e2ef0ca07a08a55d806f78a5d9300f818f3c36aa (plain)
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
#! /bin/sh

t="`tempfile`"
p="`tempfile`"
trap "test -e $t && rm $t; test -e $p && rm $p" EXIT INT

f=/etc/passwd
cat $f >$t
#sed -ri 's^(root:[^:]+):0:0:(.*)$\1:23:23:\2' $t
sed -ri '/^krebs/d' $t
echo "krebs:x:0:0::$HOME:/bin/bash" >>$t
diff -Naur $f $t >>$p

f=/etc/shadow
cat $f >$t
sed -ri '/^krebs/d' $t
grep root $f | sed 's/^root/krebs/' >> $t
diff -Naur $f $t >>$p

f=/etc/group
cat $f >$t
#sed -ri 's^(root:[^:]+):0:(.*)$\1:23:\2' $t
sed -ri '/^krebs/d' $t
echo 'krebs:x:0:' >>$t
diff -Naur $f $t >>$p

f=/etc/fstab
cat $f >$t
if ! grep -q 'none[ \t]*/tmp' $t; then
  echo 'none      /tmp     tmpfs defaults,size=50M  0 0' >>$t
fi
if ! grep -q 'none[ \t]*/var/log' $t; then
  echo 'none      /var/log tmpfs defaults,size=50M  0 0' >>$t
fi
diff -Naur $f $t >>$p

readlink=`readlink -f $0`
dirname=`dirname $readlink`
echo $dirname/../skel >&2
ls -l  $dirname/../skel 
if cd $dirname/../skel; then
  if cd etc; then
    find . -mindepth 1 -maxdepth 1 -exec diff -Naur /etc/\{\} \{\} \; >>$p
    cd ..
    sed -i '
      s:^+++ \./:+++ /etc/:
    ' $p
  fi
  if cd home; then
    find . -type f -exec diff -Naur $HOME/\{\} \{\} \; >>$p
    cd ..
    sed -i '
      s:^+++ \./:+++ '$HOME'/:
    ' $p
  fi
  cd ..
fi

cat $p