[dahdi-commits] tzafrir: branch tools/2.6 r10518 - /tools/branches/2.6/build_tools/

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Thu Mar 15 16:45:21 CDT 2012


Author: tzafrir
Date: Thu Mar 15 16:45:17 2012
New Revision: 10518

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10518
Log:
improve build_tools/dump_sys_state

* Use the new dahdi_sysfs_copy script
* Clean old/unused code
* Add notification output
* Now always creates a tarball - the gzipped copy is many times smaller.
* Without arguments, tarball name is:
    sys_dump.<hostname>_<date>_<time>.tar.gz

Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10497

Modified:
    tools/branches/2.6/build_tools/dump_sys_state

Modified: tools/branches/2.6/build_tools/dump_sys_state
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.6/build_tools/dump_sys_state?view=diff&rev=10518&r1=10517&r2=10518
==============================================================================
--- tools/branches/2.6/build_tools/dump_sys_state (original)
+++ tools/branches/2.6/build_tools/dump_sys_state Thu Mar 15 16:45:17 2012
@@ -31,117 +31,46 @@
 #  # And then later:
 #  DAHDI_VIRT_TOP="$PWD/my_sys_state" dahdi_genconf
 
-name=dahdi_sys_state_dump
-
-usage() {
-  echo "$0: dump system data for Dahdi-Perl"
-  echo "Usage: $0 [<name>]]"
-  echo ""
-  echo "<name>: name of directory/tarball to create. Default: $name"
-}
-
-output_tar() {
-  gzip -9 >$name.tar.gz
-}
-
-output_cpio() {
-  gzip -9 >$name.cpio.gz
-}
-
-output_dir() {
-  rm -rf $name
-  mkdir -p $name
-  cd $name
-  #tar xf -
-  cpio -id
-}
+mydir=`dirname $0`
+dahdi_sysfs_copy="$mydir/dahdi_sysfs_copy"
 
 # Give usage message on expected texts
-case $1 in 
-  help | -* ) usage; exit 1;;
-esac
 
-if [ "$1" != '' ]; then
-  name="$1"
+if [ "$#" -ne 0 ]; then
+	echo >&2 "Usage: $0"
+	exit 1
 fi
 
-# funky permissions on procfs. Sadly rm -f does not kill them.
-if [ -d "$name" ]; then
-  chmod -R u+w "$name"
-fi
-rm -rf "$name"
-mkdir -p "$name"
+id="sys_dump.`hostname`_`date +%F_%H.%M.%S`"
+tarball="$id.tar.gz"
 
-# delete a (potentially empty) list of files
-rm_files() {
-	xargs rm -f rm_files_non_existing_file
-}
+tmpdir=`mktemp -td 'dahdi_dump.XXXXXX'`
+echo -n >&2 "Creating ... "
+trap "[ -d '$tmpdir' ] && rm -rf '$tmpdir'" 0 1 2 15
+
+topdir="$tmpdir/$id"
 
 if [ -r /proc/bus/usb/devices ]; then
-	mkdir -p "$name/proc/bus/usb"
-	cp -a /proc/bus/usb/devices "$name/proc/bus/usb/"
+	mkdir -p "$topdir/proc/bus/usb"
+	cp -a /proc/bus/usb/devices "$topdir/proc/bus/usb/"
 fi
 
 if [ -d /proc/dahdi ]; then
-	mkdir -p "$name/proc/dahdi"
+	mkdir -p "$topdir/proc/dahdi"
 	if find /proc/dahdi -type f >/dev/null; then
-		cp -a /proc/dahdi/* "$name/proc/dahdi/" 
+		cp -a /proc/dahdi/* "$topdir/proc/dahdi/"
 	fi
 fi
 
 if [ -d /proc/xpp ]; then
-	mkdir -p "$name/proc/xpp"
+	mkdir -p "$topdir/proc/xpp"
 	if find /proc/xpp -type f >/dev/null; then
-		cp -a /proc/xpp/* "$name/proc/xpp/" 
-		find "$name/proc/xpp" -type f -name command | rm_files
+		cp -a /proc/xpp/* "$topdir/proc/xpp/"
+		find "$topdir/proc/xpp" -type f -name command -exec rm -f '{}' ';'
 	fi
 fi
 
-# FIXME: the following grab tons of files from sysfs. Any way to do with
-# less information?
-pci_dev_pat='/sys/devices/pci*'
-mkdir -p "$name/sys/devices"
-cp -a $pci_dev_pat "$name/sys/devices/" 2>/dev/null
-
-for bus in astribanks xpds pci pci_express usb; do
-	if [ -d /sys/bus/$bus ]; then
-		mkdir -p "$name/sys/bus/"
-		cp -a /sys/bus/$bus "$name/sys/bus/" 2>/dev/null
-	fi
-done
-
-# Remove PCI devices of irelevan classes:
-irrelevant_devs() {
-	grep . "$name"/$pci_dev_pat/0*/class "$name"/$pci_dev_pat/0*/0*/class \
-	| perl -n -e '# Perl provides commented regexes:
-		next unless m{/class:( # The following is a list of device classes
-			# that can be safely removed:
-			0x060000 | # Host bridge
-			0x030000 | # VGA compatible controller
-			0x038000 | # Display controller
-			0x040300 | # Audio device
-			0x060401 | # PCI bridge
-			0x060100 | # ISA bridge
-			0x01018a | # IDE interface
-			0x01018f | # IDE interface
-			0x0c0500 | # SMBus
-			0x060700 | # CardBus bridge
-			0x0c0010 | # FireWire (IEEE 1394)
-			# The following are not to be removed:
-			#0x0c0300 | # USB Controller (UHCI?)
-			#0x060400 | # PCI bridge
-			#0x0c0320 | # USB Controller (EHCI?)
-			#0x020000 | # Ethernet controller
-			#0x0c0010 | # Network controller: (Wifi?)
-		)$}x;
-		# Leave out just the name of the node:
-		s{/[^/]*$}{};
-		print;
-		print "\n"
-	'
-}
-
-# FIXME: deleting those seems to remove common 'vendor' directories
-# and mess things up. Skip it for now.
-#rm -rf `irrelevant_devs`
-
+"$dahdi_sysfs_copy" "$topdir"
+echo -n >&2 "tarball ... "
+( cd "$tmpdir" && tar czf - . ) > "$tarball";
+echo >&2 "ready in '$tarball'"




More information about the dahdi-commits mailing list