save-config: include findchanged
authorMichael Prokop <mika@grml.org>
Wed, 14 Dec 2011 11:39:44 +0000 (12:39 +0100)
committerMichael Prokop <mika@grml.org>
Wed, 14 Dec 2011 11:39:44 +0000 (12:39 +0100)
The script findchanged was removed from grml-scripts in
c08b156abb0b2b1b1335cb1ada0c08758553238b, since only
save-config depends on it lets include it inline.

Thanks: Charles Hewson for the bugreport

bin/save-config

index 276515a..a7dce5d 100755 (executable)
@@ -24,7 +24,7 @@
   LC_ALL=C
   [[ $(id -u) != 0 ]] && runas='sudo' # important for /etc
 
-  check4progs findchanged tar || { echo "Sorry, can't continue. Exiting.">&2 ; exit 1 }
+  check4progs tar || { echo "Sorry, can't continue. Exiting.">&2 ; exit 1 }
 
   CONFIG=/etc/grml/saveconfig
   [ -r "$CONFIG" ] && . $CONFIG
@@ -50,6 +50,18 @@ debug(){
 # set -x
 }
 
+findchanged() {
+  [ -n "$1" ] || return 1
+
+  if [ -d "$1" ]; then
+    for i in $(cd "$1"; find . -type f 2>/dev/null | sed 's,^\./,,g' | grep -v ' '); do
+      cmp -s "$1/$i" "$2/$i" || echo "$1/$i"
+    done
+  elif [ -e "$1" ]; then
+    cmp -s "$1" "$2" || echo "$1"
+  fi
+}
+
 bailout(){
   rm -f "$FILELIST"
   rm -f "$MAILFILE"