[svn-commits] tzafrir: branch tools/tzafrir/perl-sysstate r7718 - /tools/team/tzafrir/perl-...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Dec 21 16:36:52 CST 2009


Author: tzafrir
Date: Mon Dec 21 16:36:50 2009
New Revision: 7718

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7718
Log:
A script to dump the current system state.

Dumps relevant files from /sys and /proc (well, along with a substential
part /sys. At least for now).

Added:
    tools/team/tzafrir/perl-sysstate/build_tools/dump_sys_state   (with props)

Added: tools/team/tzafrir/perl-sysstate/build_tools/dump_sys_state
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/perl-sysstate/build_tools/dump_sys_state?view=auto&rev=7718
==============================================================================
--- tools/team/tzafrir/perl-sysstate/build_tools/dump_sys_state (added)
+++ tools/team/tzafrir/perl-sysstate/build_tools/dump_sys_state Mon Dec 21 16:36:50 2009
@@ -1,0 +1,110 @@
+#!/bin/sh
+
+# dump_sys_state: dump some /sys and /proc files to a directory.
+# $Id$
+#
+# Written by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+# Copyright (C) 2009, Xorcom
+#
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA
+
+# The DAHDI-perl modules will use such a dump instead of the files from
+# the real system if DAHDI_VIRT_TOP is set to the root.
+#
+#  ./build_tools/dump_sys_state my_sys_state
+#
+#  # 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
+}
+
+# Give usage message on expected texts
+case $1 in 
+  help | -* ) usage; exit 1;;
+esac
+
+if [ "$1" != '' ]; then
+  name="$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"
+
+# delete a (potentially empty) list of files
+rm_files() {
+	xargs rm -f rm_files_non_existing_file
+}
+
+if [ -r /proc/bus/usb/devices ]; then
+	mkdir -p "$name/proc/bus/usb"
+	cp -a /proc/bus/usb/devices "$name/proc/bus/usb/"
+fi
+
+if [ -d /proc/dahdi ]; then
+	mkdir -p "$name/proc/dahdi"
+	if find /proc/dahdi -type f >/dev/null; then
+		cp -a /proc/dahdi/* "$name/proc/dahdi/" 
+	fi
+fi
+
+if [ -d /proc/xpp ]; then
+	mkdir -p "$name/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
+	fi
+fi
+
+# FIXME: the following grab tons of files from sysfs. Any way to do with
+# less information?
+mkdir -p "$name/sys/devices"
+cp -a /sys/devices/pci* "$name/sys/devices/" 2>/dev/null
+
+for bus in astribanks xpds pci 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

Propchange: tools/team/tzafrir/perl-sysstate/build_tools/dump_sys_state
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tools/team/tzafrir/perl-sysstate/build_tools/dump_sys_state
------------------------------------------------------------------------------
    svn:executable = *

Propchange: tools/team/tzafrir/perl-sysstate/build_tools/dump_sys_state
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: tools/team/tzafrir/perl-sysstate/build_tools/dump_sys_state
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the svn-commits mailing list