From 3245a616edf68d9c33fdba8b50015e4b5c96cdae Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Sat, 27 Feb 2010 15:10:45 +0100 Subject: [PATCH] save-config: search for modified files and symlinks in /etc --- bin/save-config | 19 ++++++++++++------- debian/changelog | 9 +++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bin/save-config b/bin/save-config index 63483c0..276515a 100755 --- a/bin/save-config +++ b/bin/save-config @@ -4,7 +4,6 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Son Mai 13 11:46:44 CEST 2007 [mika] ################################################################################ # some zsh-stuff {{{ @@ -25,7 +24,6 @@ LC_ALL=C [[ $(id -u) != 0 ]] && runas='sudo' # important for /etc - check4progs mutt || echo "Warning, mutt not available for mail handling.">&2 check4progs findchanged tar || { echo "Sorry, can't continue. Exiting.">&2 ; exit 1 } CONFIG=/etc/grml/saveconfig @@ -41,6 +39,7 @@ MAILFILE="$TMPDIR/mail.txt" [ -n "$FILELIST" ] || FILELIST=$(mktemp $TMPDIR/filelist.XXXXXX) +# }}} # functions {{{ debug(){ @@ -122,7 +121,7 @@ save_grmlhome(){ save_etc(){ debug "save etc" if [ -n "$NEWLAYOUT" ] ; then - $runas find /live/cow/etc | sed -e 's#/live/cow## ; /etc$/d' >> $FILELIST + $runas find /live/cow/etc -type f -o -type l | sed -e 's#/live/cow## ; /etc$/d' >> $FILELIST else $runas findchanged /etc /GRML/etc >> $FILELIST fi @@ -131,7 +130,7 @@ save_etc(){ save_configdir(){ debug "save configdir" if [ -d $HOME/config ] ; then - ls $HOME/config/* >> $FILELIST 2>/dev/null + ls $HOME/config/* >> $FILELIST 2>/dev/null ls $HOME/config/.* >> $FILELIST 2>/dev/null fi } @@ -141,9 +140,10 @@ create_config(){ if ! [ -r "$FILELIST" ]; then echo "Sorry, filelist $FILELIST could not be read." >&2 echo "Error when generating $FILENAME." >&2 + exit 1 else # GNU tar sucks so much, really. Avoid the "file changed as we read it": - tar cf /dev/null /etc + tar cf /dev/null /etc 2>/dev/null # now really execute the according tar command: BZIP2=-9 $runas tar -T - -cpPjf "$FILENAME" <"$FILELIST" && \ echo "Successfully stored configuration in file $FILENAME" || \ @@ -203,7 +203,7 @@ parse_options() fi if [[ "$o_mail" != "" ]]; then - check4progs mutt || { echo "Sorry, mutt not available for sending mail. Exiting.">&2 ; exit 1 } + check4progs mutt || { echo "Sorry, mutt not available for sending mail. Exiting.">&2 ; exit 1 ; } recipient=$o_mail[2] debug "send mail to $recipient" echo "Created on $DATE on host $HOSTNAME running grml $GRML_VERSION" > $MAILFILE @@ -219,23 +219,28 @@ runit(){ save_home SETSAVE=1 fi + if [[ $SAVE_GRMLHOME == "yes" ]]; then debug "running save_grmlhome" save_grmlhome SETSAVE=1 fi + if [[ $SAVE_ETC == "yes" ]] ; then debug "running save_etc" save_etc SETSAVE=1 fi + if [[ $SAVE_CONFIGDIR == "yes" ]] ; then debug "running save_configdir" save_configdir SETSAVE=1 fi + if [ -z $SETSAVE ] ; then - echo "Sorry, you did not select any configuration which should be saved. Exiting." ; exit 1 + echo "Sorry, you did not select any configuration which should be saved. Exiting.">&2 + exit 1 fi } diff --git a/debian/changelog b/debian/changelog index d17e2db..0ce2adb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +grml-autoconfig (0.9.8) unstable; urgency=low + + * save-config: search for modified files and symlinks in /etc + only so not the full directories are stored in the resulting + tarball. Thanks to Alexander Menk for the bugreport. + [Closes: issue765] + + -- Michael Prokop Sat, 27 Feb 2010 15:07:56 +0100 + grml-autoconfig (0.9.7) unstable; urgency=low * Improve chvt code for serial console. -- 2.1.4