From 937099fb6d2360129ab3fa5d698bd5c70d14e6d5 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 28 May 2011 14:34:33 +0200 Subject: infest: Major Refactoring --- modules/infest/bin/make-patch | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 modules/infest/bin/make-patch (limited to 'modules/infest/bin/make-patch') diff --git a/modules/infest/bin/make-patch b/modules/infest/bin/make-patch new file mode 100755 index 00000000..2d0b11ef --- /dev/null +++ b/modules/infest/bin/make-patch @@ -0,0 +1,61 @@ +#! /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' $ft +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 +diff -Naur $f $t >>$p + +f=/etc/fstab +cat $f >$t +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` +if pushd $dirname/../skel >/dev/null; then + if pushd etc >/dev/null; then + find . -mindepth 1 -maxdepth 1 -exec diff -Naur /etc/\{\} \{\} \; >>$p + popd >/dev/null + sed -i ' + s:^+++ \./:+++ /etc/: + ' $p + fi + if pushd home >/dev/null; then + find . -type f -exec diff -Naur $HOME/\{\} \{\} \; >>$p + popd >/dev/null + sed -i ' + s:^+++ \./:+++ '$HOME'/: + ' $p + fi + popd >/dev/null +fi + +cat $p -- cgit v1.2.3