July 26, 2007

host clock rate change request

kernel: /dev/vmmon[xxxx]: host clock rate change request yyyy -> zzzz

みたいなログがわんさかでてどうしたものかと思ってたが、解決方法を見つけたのでメモ。

kernel configを

CONFIG_HZ_1000=y
CONFIG_HZ=1000
でkernelをbuildするか、.vmxファイルに
host.useFastclock = FALSE
を追加することで収まる。CONFIG_HZ=1000は未確認。sidの吊るしkernel 2.6.22-1で確認。ソースはこちら

diredでgを押さずにbufferを更新

若干誇張しすぎてる気もするけど、とりあえずgを押せと言われるシチュエーションに於いてgを押さずに勝手に更新してもらう方法。

(defadvice dired-noselect (after my-dired-noselect (dir-or-list &optional switches) activate)
(if (dired-directory-changed-p dir-or-list)
(with-current-buffer ad-return-value
(let ((pos (point))
(current-file (dired-get-filename)))
(revert-buffer)
(unless (dired-goto-file current-file)
(goto-char pos))
(message "Dired buffer `%s' has been updated." dir-or-list)))))

July 23, 2007

ghostscript 8.60とromfs

最 近のgsは%rom%lib/とかsearch pathに追加されてんのね。いくら/usr/share/ghostscriptの下のファイルを変更しても反映されんのでしばらく悩んだ。build 時に必要なファイルすべてmkromfsを経由してgsromfs.cとして変換され、それをlibgsの中に組み込んでしまうようだ。

まあそれはそれでありだと思うけど、それなら/usr/share/ghostscriptとか持つ必要ないよね。混乱するだけ。

July 10, 2007

rieceからsshのトンネルを掘る

環境の都合上clientからIRC proxyまでの経路をsshでトンネルを掘っている。これを裏でshell scriptを使って接続していたんだけど、めんどいので、riece動かした時になんとかしてみようと思った。

というわけで以下結果。

(eval-after-load "riece"
'(progn
(defun irc-ssh-tunnel-negotiates-connection (process event)
(message "ssh tunnel established")
(set-process-filter process nil)
(setq irc-ssh-tunnel-negotiating nil))
(defun make-tunnel (irc-ssh-user irc-ssh-server)
(setq irc-ssh-tunnel-negotiating t)
(if (condition-case nil
(let* ((buf (generate-new-buffer " *irc-tunnel*"))
(process (open-network-stream
"irc-tunnel"
buf
"localhost"
16667)))
(delete-process process)
(kill-buffer buf)
nil)
(error t))
(progn
(setq process
(start-process "irc-ssh"
nil
"ssh"
(concat irc-ssh-user "@" irc-ssh-server) "-C"
"-L 16667:localhost:16667"))
(set-process-filter process 'irc-ssh-tunnel-negotiates-connection)
(while irc-ssh-tunnel-negotiating
(sit-for 0.1)))))
(add-hook 'riece-after-load-startup-hook
'(make-tunnel "user" "host"))))
16667でlistenしてるのがなければsshでport forwarding、繋がるまでラグがあるので、set-process-filterで何か飛んでくるのを待ってからhookから抜けるようにしてみた。

June 24, 2007

flets squareへのroute

今さらなことだけれど、flets squareへのroutingを手でいじったりちょくちょく確認するのが面倒なので、スクリプトでも書いて勝手に更新するようにしてみた。

#! /usr/bin/env ruby
#

require 'open-uri'
require 'htree'
require 'rexml/document'
require 'tempfile'

scriptfile = '/usr/local/sbin/flets-route.sh'
pppdev = 'ppp1'

ht = HTree.parse(open('http://routing.flets/routing.html').read)
xml = REXML::XPath.match(ht.to_rexml,'/html/body/text()')
tmp = Tempfile.new('flets-route')
fp = tmp.open
fp.printf("#! /bin/sh\n" \
"\n" \
"if [ \"x$1\" = \"xup\" ]; then\n" \
" OP=\"add\"\n" \
"else\n" \
" OP=\"del\"\n" \
"fi\n")
lines = xml[0].to_s.split("\n").grep(/\ARoute\d+=/)
exit(1) if lines.empty?
lines.each do |line|
if line =~ /Route\d+=Add,((?:\d{1,3}\.){3}\d{1,3}),((?:\d{1,3}\.){3}\d{1,3})/
then
fp.printf("/sbin/route $OP -net %s netmask %s dev $2\n", $1, $2)
end
end
fp.close

updated = false
if File.exist?(scriptfile) then
system("diff #{scriptfile} #{fp.path} > /dev/null")
if $? != 0 then
system("#{scriptfile} down #{pppdev}")
File.rename(scriptfile, "#{scriptfile}.#{Time.now.strftime('%Y%m%d')}")
updated = true
end
else
updated = true
end
if updated then
File.rename(fp.path, scriptfile)
File.chmod(0755, scriptfile)
system("#{scriptfile} up #{pppdev}")
end

cronにでも一日一回チェックするように仕込んどけばおk。動かす前にflets squareへ接続できるようにしておく必要はあるけど、そのあたりの設定はぐぐると山ほど出てくるので割愛。出来たファイルは/etc/ppp/{ip -up.d,ip-down.d}もしくはそれに類似するものから呼ぶようにしておけば、rebootなりなんかの都合でpoff/ponする必要があっ たりしても問題なし。