From bf052f6a6a376d6f0c4e93bd606d2674718a9f06 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Thu, 28 Jan 2010 22:00:31 +0100 Subject: [PATCH] Add usage info, and command line arguments. --- etcdiff.sh | 74 ++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/etcdiff.sh b/etcdiff.sh index 3014c4b..4ee0212 100755 --- a/etcdiff.sh +++ b/etcdiff.sh @@ -1,7 +1,7 @@ #!/bin/sh # # etcdiff (deb-etcdiff?) shows how your current /etc dir -# diverges from the debian distribution standard one. +# diverges from the debian default one. # # Copyright (C) 2008,2009,2010 Antonio Ospite # License: GPLv2 or later @@ -18,34 +18,56 @@ TEMPDIR=${BASEDIR}/temp CACHEDIR=${BASEDIR}/cache REPORTDIR=${BASEDIR}/reports +usage() +{ + echo "usage: $0 [|] + +etcdiff shows how your /etc dir differs from the debian default one + +etcdiff by explicit file list: + FILES='/etc/sysctl.conf /etc/updatedb.conf' + for file in \$FILES; + do + $0 file \$file + done + +etcdiff bycommand generated file list + FILES=\$(find /etc/apache2 -type f -perm /o+r | grep -v '.dpkg-') + for file in \$FILES; + do + $0 file \$file + done + +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 + +etcdiff the whole /etc system directory + $0 system +" +} + rm $PROMPT_RM -rf $TEMPDIR && mkdir $TEMPDIR rm $PROMPT_RM -rf $CACHEDIR && mkdir $CACHEDIR rm $PROMPT_RM -rf $REPORTDIR && mkdir $REPORTDIR . $BASEDIR/etcdiff.include -# Examples of file query - -# by explicit file list -#FILES="/etc/sysctl.conf /etc/updatedb.conf" -#for file in $FILES; -#do -# etcdiff_by_file $file -#done - -# by file list generated by a command -#FILES=$(find /etc/apache2 -type f -perm /o+r | grep -v '.dpkg-') -#for file in $FILES; -#do -# etcdiff_by_file $file -#done - -# by package name -#etcdiff_by_package cherokee -#etcdiff_by_package mlocate -#etcdiff_by_package apache2-doc -#etcdiff_by_package apache2.2-common -#etcdiff_by_package libapache2-mod-php5 -#etcdiff_by_package hostapd - -#etchdiff_system +case $1 in + file) + etcdiff_by_file $2 + ;; + package) + etcdiff_by_package $2 + ;; + system) + etcdiff_system + ;; + *) + usage + ;; +esac -- 2.1.4