From dc9ff8085a9701ec6db59c97ca73e29de4574ecc Mon Sep 17 00:00:00 2001 From: Frodo Looijaard Date: Thu, 24 Dec 1998 01:22:19 +0000 Subject: [PATCH] New program, which generates `bus' lines for your config file git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@109 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/config/grab_busses.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 prog/config/grab_busses.sh diff --git a/prog/config/grab_busses.sh b/prog/config/grab_busses.sh new file mode 100755 index 00000000..3d2bc769 --- /dev/null +++ b/prog/config/grab_busses.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# This simple shell script grabs the contents of /proc/bus/i2c and outputs it +# in sensors.conf format through stdout. You can use it to generate those +# nasty 'bus' statements in config files. + +if [ $# = 0 ] ; then + file=/proc/bus/i2c +elif [ $# = 1 ] ; then + file="$1" +else + echo "Syntax: grab_busses [file]" >&2 + exit 1 +fi + +if [ ! -e "$file" ]; then + echo "Can't find file \`$file';"\ + "try \`modprobe i2c-proc' for /proc/bus/i2c" >&2 + exit 1 +fi + +cat -- "$file" | awk \ + ' BEGIN { FS = "\t" } + { sub(" *$","",$3) + sub(" *$","",$4) + printf "bus \"%s\" \"%s\" \"%s\"\n",$1,$3,$4 } + { nrlines++ } + END { printf "Total lines: %d\n",nrlines > "/dev/stderr" } + '