diff options
-rwxr-xr-x | savelocaltweaks | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/savelocaltweaks b/savelocaltweaks index 7f2c84d..7426660 100755 --- a/savelocaltweaks +++ b/savelocaltweaks @@ -4,8 +4,11 @@ basedir="/etc" targetdir="/tmp/localtweaks" +includefile="/etc/local/localtweaks.include" +excludefile="/etc/local/localtweaks.exclude" +extensions=".orig old" -for ext in .orig .old; do +for ext in $extensions; do extfiles="`find $basedir -name \*$ext`" for extfile in $extfiles; do xextfile="${extfile%$ext}" @@ -14,20 +17,19 @@ for ext in .orig .old; do done includes="" +if [ -d "`dirname $includefile`" ] && [ -r $includefile ]; then + includes="`cat $includefile`" + for include in $includes; do + files="$files ${include#$basedir}" + done +fi + excludes="" -if [ -d /etc/local ]; then - if [ -r /etc/local/localtweaks.include ]; then - includes="`cat /etc/local/localtweaks.include`" - for include in $includes; do - files="$files ${include#$basedir}" - done - fi - if [ -r /etc/local/localtweaks.exclude ]; then - xexcludes="`cat /etc/local/localtweaks.exclude`" - for exclude in $xexcludes; do - excludes="$excludes ${exclude#$basedir}" - done - fi +if [ -d "`dirname $excludefile`" ] && [ -r $excludefile ]; then + xexcludes="`cat $excludefile`" + for exclude in $xexcludes; do + excludes="$excludes ${exclude#$basedir}" + done fi # process all files once each @@ -37,13 +39,13 @@ for file in `for x in $files; do echo $x; done | uniq | sort`; do [ "$file" = "$exclude" ] && continue 2 done - if [ -e $basedir/${file}.orig ]; then - ext=".orig" - elif [ -e $basedir/${file}.old ]; then - ext=".old" - else - ext="" - fi + ext="" + for xext in $extensions; do + if [ -e $basedir/$file$xext ]; then + ext="$xext" + continue + fi + done newdir="$targetdir/$basedir/`dirname $file`" mkdir -p $newdir |