projects
/
etcdiff.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Disable interactive removal. Don't let -i to be overridden by -f.
[etcdiff.git]
/
etcdiff.sh
diff --git
a/etcdiff.sh
b/etcdiff.sh
index
b8a3be6
..
45587cb
100755
(executable)
--- a/
etcdiff.sh
+++ b/
etcdiff.sh
@@
-1,55
+1,73
@@
#!/bin/sh
#
# etcdiff (deb-etcdiff?) shows how your current /etc dir
#!/bin/sh
#
# etcdiff (deb-etcdiff?) shows how your current /etc dir
-# diverges from the debian d
istribution standard
one.
+# diverges from the debian d
efault
one.
#
#
-# Copyright (C) 2008 Antonio Ospite <ospite@studenti.unina.it>
+# Copyright (C) 2008
,2009,2010
Antonio Ospite <ospite@studenti.unina.it>
# License: GPLv2 or later
# License: GPLv2 or later
+#
+#set -x
+#set -e
-set -ex
-
-PROMPT_RM=-i
+#PROMPT_RM=-i
DEBIANMIRROR="http://ftp.it.debian.org/debian"
DEBIANMIRROR="http://ftp.it.debian.org/debian"
-rm $PROMPT_RM -r temp && mkdir temp
-rm $PROMPT_RM -r archives && mkdir archives
-rm $PROMPT_RM -r conf && mkdir -p conf/patches
-
-USERMODE="-perm /o+r"
-MAXDEPTH="-maxdepth 1"
+BASEDIR=$(dirname $0)
+TEMPDIR=${BASEDIR}/temp
+CACHEDIR=${BASEDIR}/cache
+REPORTDIR=${BASEDIR}/reports
-#FILES="/etc/sysctl.conf /etc/init.d/procps /etc/passwd-"
-FILES=$(find /etc/ $MAXDEPTH -type f $USERMODE | grep -v '.dpkg-')
+usage()
+{
+ echo "usage: $0 <file|package|system> [<file name>|<package name>]
-for file in ${FILES};
-do
- echo "-> $file"
+etcdiff shows how your /etc dir differs from the debian default one
- # Find out what installed package provides the config file
- PACKAGE=$(dpkg-query -S "$file" | cut -d ':' -f 1 | uniq 2> /dev/null)
+etcdiff by explicit file list:
+ FILES='/etc/sysctl.conf /etc/updatedb.conf'
+ for file in \$FILES;
+ do
+ $0 file \$file
+ done
-
# Copy the whole file if it is not provided by defaul
t
- if [ "x$PACKAGE" == "x" ];
- then
- cp "$file" conf/
-
continu
e
- fi
+
etcdiff bycommand generated file lis
t
+ FILES=\$(find /etc/apache2 -type f -perm /o+r | grep -v '.dpkg-')
+ for file in \$FILES;
+ do
+
$0 file \$fil
e
+ done
- # Get the package from the repository and diff
+etcdiff by package name
+ $0 package cherokee
+ $0 package mlocate
+ $0 package apache2-doc
+ $0 package apache2.2-common
+ $0 package libapache2-mod-php5
+ $0 package hostapd
- FILENAME=$(apt-cache show $PACKAGE | grep ^Filename | cut -d ' ' -f 2-)
- ARCHIVE=$(basename $FILENAME)
+etcdiff the whole /etc system directory
+ $0 system
+"
+}
- (cd archives && wget -q -nc -c $DEBIANMIRROR/$FILENAME)
- dpkg -x archives/$ARCHIVE temp/
+rm -rf $PROMPT_RM $TEMPDIR && mkdir $TEMPDIR
+rm -rf $PROMPT_RM $CACHEDIR && mkdir $CACHEDIR
+rm -rf $PROMPT_RM $REPORTDIR && mkdir $REPORTDIR
- diff -q temp/$file $file > /dev/null
- if [ $? -eq 1 ];
- then
- diff -u temp/$file $file > conf/patches/$(basename $file).patch
- else
- echo "$file: not changed"
- fi
+. $BASEDIR/etcdiff.include
-done
+case $1 in
+ file)
+ etcdiff_by_file $2
+ ;;
+ package)
+ etcdiff_by_package $2
+ ;;
+ system)
+ etcdiff_system
+ ;;
+ *)
+ usage
+ ;;
+esac