この日記にはツッコミを入れられます。 ツッコミを入れたい日付をクリックすると、フォームが現れます。
xreaでtDiaryを使う方法はxrea.com で tDiary を使う方法やインストールメモやXREA + tDiary + Namazuをどうぞ。
レビューしたと言うことでプログラミングRuby 1.9 −言語編−とプログラミングRuby 1.9 −ライブラリ編−が届いていた。
第 35 回 関西 Debian 勉強会 に行ってきた。 話の途中でもどんどん質問などが出ていたりして非常に楽しくてよかったです。
事前課題のところに書いていたのは、以前「update-motd」というのがどこで実行されているのかよくわからず、調べていたらpamにubuntuの独自パッチが当たっていて、そこで実行されていた、ということがあって、それが squeeze にも入りそう、というのが1点。 もう1つは https://wiki.ubuntu.com/GccSsp で引っかかったという話。
bashのシェルスクリプトで定義されているはずのaliasがよべなくて不便と思ってIRCで話してみたら、「shopt -s expand_aliases」というのを教えてもらった。
$ cat a.sh #!/bin/bash alias hoge='echo hoge' hoge $ sh ./a.sh hoge $ bash ./a.sh ./a.sh: line 3: hoge: コマンドが見つかりません $
違う環境でワンライナーで試してたら、ちょっとはまった。
% bash -c 'shopt -s expand_aliases;alias hoge="echo hoge";type hoge;hoge' hoge is aliased to `echo hoge' bash: hoge: コマンドが見つかりません % bash -c 'shopt -s expand_aliases;alias hoge="echo hoge";type hoge hoge' hoge is aliased to `echo hoge' hoge %
今は backports に dkms 2.1.1.2-2~bpo50+1 があるので /etc/apt/preferences に
Package: dkms Pin: release a=lenny-backports Pin-Priority: 999
と書いて dkms をインストール。
USBRH driver for Linux からドライバをとってきて /usr/src/usbrh-0.0.8 において「chown -R root:src」とかしておく。
以下の内容の /usr/src/usbrh-0.0.8/dkms.conf を設置。
PACKAGE_NAME="usbrh" PACKAGE_VERSION="0.0.8" BUILT_MODULE_NAME[0]="usbrh" BUILT_MODULE_LOCATION[0]="src/" MAKE[0]="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build/src" DEST_MODULE_LOCATION[0]="/kernel/../extra/" AUTOINSTALL="yes" REMAKE_INITRD="yes"
$ sudo dkms add -m usbrh -v 0.0.8
Creating symlink /var/lib/dkms/usbrh/0.0.8/source ->
/usr/src/usbrh-0.0.8
DKMS: add Completed.
$ sudo dkms build -m usbrh -v 0.0.8
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area....
make KERNELRELEASE=2.6.26-2-amd64 -C /lib/modules/2.6.26-2-amd64/build M=/var/lib/dkms/usbrh/0.0.8/build/src....
cleaning build area....
DKMS: build Completed.
$ sudo dkms install -m usbrh -v 0.0.8
usbrh.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/2.6.26-2-amd64/updates/dkms/
depmod....
Updating initrd
Making new initrd as /boot/initrd.img-2.6.26-2-amd64
(If next boot fails, revert to the .bak initrd image)
update-initramfs........
DKMS: install Completed.
$
/etc/initramfs-tools/modules に usbrh を追加し忘れていたので、一度 uninstall してから install し直した。
/etc/munin/plugins/usbrh 作成。 (2010-06-17 追記: ツッコミにある1行抜けていたのを修正。 最新は http://gist.github.com/441401 に置くことにした。)
#!/bin/sh
case "$1" in
autoconf)
if [ -r /proc/usbrh/0/status ]; then
echo yes
exit 0
else
echo no
exit 1
fi
;;
config)
echo 'graph_title USBRH'
echo 'graph_args -l 0 --base 1000'
echo 'graph_vlabel temperature(C) and humidity(%RH)'
echo 'graph_category sensors'
cd /proc/usbrh
for n in *; do
echo "humidity_$n.label humidity $n"
echo "humidity_$n.draw LINE2"
echo "humidity_$n.info humidity $n"
echo "temperature_$n.label temperature $n"
echo "temperature_$n.draw LINE2"
echo "temperature_$n.info temperature $n"
done
exit 0
;;
esac
for status in /proc/usbrh/*/status; do
n=$(basename $(dirname $status))
# retry when failed to get temperature/humidity
for i in 1 2 3 4 5; do
stat="$(cat $status)"
#mkdir /tmp/usbrh
#{ date; echo $stat; } >> /tmp/usbrh/usbrh-$$.log
if expr "$stat" : "^t">/dev/null; then
break
fi
sleep 1
done
#echo "$stat" | sed -e "s/t:([.0-9]*) h:([.0-9]*)/temperature_$n.value \$1\nhumidity_$n.value \$2/"
#echo $stat | sed -e "s/t:/temperature_$n.value /" -e "s/ h:/\nhumidity_$n.value /"
echo $stat | sed -e "s/t:\\([.0-9]*\\) h:\\([.0-9]*\\).*/temperature_$n.value \\1\nhumidity_$n.value \\2/"
done
Ubuntu 10.04 LTS だと udev で文句を言われたのでこう変更した。
% cat /etc/udev/rules.d/10-usbrh.rules
# USBRH (http://www2.strawberry-linux.com/products/usbrh/) rules
# written by Tetsuya KIMATA <kimata@acapulco.dyndns.org>
# $Id: 10-usbrh.rules 40 2009-09-04 16:13:44Z kimata $
#BUS=="usb", SYSFS{manufacturer}=="Strawberry Linux Co.,Ltd.", SYSFS{product}=="Hygrometer/Thermometer", NAME=="%k", RUN+="/sbin/modprobe usbrh"
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1774", ATTR{idProduct}=="1001", RUN+="/sbin/modprobe usbrh"
kernel-mode quine - まめめも の Makefile, README, quine.c を /usr/src/quine-0.0.0 にコピー。 バージョンは付いていないようだったので、0.0.0 にしてみた。
/usr/src/quine-0.0.0/dkms.conf 作成。AUTOINSTALL はしない。 DEST_MODULE_LOCATION は vmware のモジュールの位置にあわせてみたが、「/lib/modules/$(uname -r)/updates/dkms/」に入るようになっていて使われていなさそう。
PACKAGE_NAME="quine" PACKAGE_VERSION="0.0.0" BUILT_MODULE_NAME[0]="quine" DEST_MODULE_LOCATION[0]="/kernel/../misc/"
dkms でインストール。
% sudo dkms add -m quine -v 0.0.0
Creating symlink /var/lib/dkms/quine/0.0.0/source ->
/usr/src/quine-0.0.0
DKMS: add Completed.
% sudo dkms build -m quine -v 0.0.0
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area....
make KERNELRELEASE=2.6.26-2-amd64 -C /lib/modules/2.6.26-2-amd64/build M=/var/lib/dkms/quine/0.0.0/build....
cleaning build area....
DKMS: build Completed.
% sudo dkms install -m quine -v 0.0.0
quine.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/2.6.26-2-amd64/updates/dkms/
depmod....
DKMS: install Completed.
%
使ってみる。 Makefile は同じではなかった。
% sudo modprobe quine % ls -al /proc/quine 合計 0 dr-xr-xr-x 2 root root 0 2010-05-29 12:57 ./ dr-xr-xr-x 110 root root 0 2010-05-27 02:34 ../ -r--r--r-- 1 root root 0 2010-05-29 12:57 Makefile -r--r--r-- 1 root root 0 2010-05-29 12:57 quine.c % diff quine.c /proc/quine/quine.c % diff Makefile /proc/quine/Makefile 1c1 < KDIR = /lib/modules/$(shell uname -r)/build --- > KDIR = /lib/modules/2.6.26-2-amd64/build %
後は消すだけ。
% sudo rmmod quine % sudo dkms uninstall -m quine -v 0.0.0 -------- Uninstall Beginning -------- Module: quine Version: 0.0.0 Kernel: 2.6.26-2-amd64 (x86_64) ------------------------------------- Status: Before uninstall, this module version was ACTIVE on this kernel. quine.ko: - Uninstallation - Deleting from: /lib/modules/2.6.26-2-amd64/updates/dkms/ - Original module - No original module was found for this module on this kernel. - Use the dkms install command to reinstall any previous module version. depmod.... DKMS: uninstall Completed. % sudo dkms remove -m quine -v 0.0.0 --all -------- Uninstall Beginning -------- Module: quine Version: 0.0.0 Kernel: 2.6.26-2-amd64 (x86_64) ------------------------------------- Status: This module version was INACTIVE for this kernel. depmod.... DKMS: uninstall Completed. ------------------------------ Deleting module version: 0.0.0 completely from the DKMS tree. ------------------------------ Done. % sudo rm -rf /usr/src/quine-0.0.0 %
✑ nanacy [CentOS 5にてですが、メチャクチャ有難く使用させてもらってます。 /etc/munin/plugins/..]
✑ znz [gistの方ではexprの代わりにcaseでチェックするようにしてみました。]