Once you have many Debian servers, maintenance would be a problem. I just counted that I have more then 30 etch servers running in several vserver machines. Sometimes, I would like to install Debian package in all of these servers. However, it takes too much time to ssh /vserver enter into every hosts, and answer the installation questions one by one.

Thanks for the debconf(1), it’s quite easy to do non-interactive installation, since debconf already provide a noninteractive frontend. All you need to do is set the configuration before you install the package. It can be done by debconf-set-selections.

First, you have to install the package in one hosts. It would be better if you install/test the package on the same distribution version and package version. Here is an example for install localepurge. localepurge is a software for superfluous locale data, that will save you some disk space. As a Chinese, I usually don’t need Spanish, Franch and any other hundreds of different locale data.

Once you install the localepurge, you can use debconf-get-selections to dump the configuration you did.  The debconf-get-selections is part of the debconf-utils. The command would look like

# debconf-get-selections |grep ^localepurge
localepurge	localepurge/quickndirtycalc	boolean	true
localepurge	localepurge/remove_no	note
localepurge	localepurge/mandelete	boolean	true
localepurge	localepurge/showfreedspace	boolean	true
localepurge	localepurge/verbose	boolean	false
localepurge	localepurge/nopurge	multiselect	en, en_US.UTF-8, zh, zh_TW, zh_TW.UTF-8
localepurge	localepurge/dontbothernew	boolean	false
localepurge	localepurge/none_selected	boolean	false

So, these are the questions the debconf will ask you. (Since the questions has different priorities, you might not be asked for all the questions) The localepurge/nopurge line is the locales data we want to keep, so we also want to let the other servers have the same settings. You can use debconf-set-selections to set the values in the other servers.

# echo "localepurge localepurge/nopurge multiselect en, en_US.UTF-8, zh, zh_TW, zh_TW.UTF-8"|debconf-set-selections

Then you can now install the package, it will use the default value you just gave. If you need to install many servser, and do not want to see the question dialogs. You can use noninteractive fronetend to bypas the questions.

# DEBIAN_FRONTEND=noninteractive dpkg-reconfigure localepurge

This is a Tips for Debian system.

Thanks clkao (高大師) for the great svn-mirror tool. I am using svn-mirror 0.68-3 on Debian Etch for mirror svn repository from the damn far and slow European svn server, so I can enjoy the super faster checkout and show the log messages on local server.

However, since the the svn server is slow and connection is not stable (otherwise I don’t need svn-mirror anyway). The connection might be dropped or the process could be killed by accident in the long mirroring process. The problem is once the program is killed (Ex: by Control+C), then it will run into a dead lock situation. You will keep seeing this messages, and never get the mirror work again.

Waiting for sync lock on /mirror/remote: openwrt:25221.

In order to fix the problem, I wrote a simple script svn-mirror-unlock.pl. It’s for clean the dead lock.

$ svn-mirror-unlock.pl
svn-mirror-unlock.pl: unlock SVMREPOS path
$ perl svn-mirror-unlock.pl unlock /home/svn mirror/remote

This is a tip for Debian.

由於 debian.org.tw 以及許多社群網站都是多人之團隊維護的系統,團隊中許多人都有 root 權限,如果團隊間沒有協調妥當,常常另一人改了設定,下一人又改回來,造成設定上得困擾。於是我們需要一個系統可以追蹤、紀錄各種設定的修改。

有些方法是把設定檔目錄丟進 svk, bzr, mercurial 等等的版本控制軟體。但是往往會忘記將改過的設定檔儲存 (commit),以至於日後又忘記是誰動的手腳。近日裝了 metche,發現他大致可以滿足我的需求。metche 的基本功能是協助你監視 /etc 下面的設定檔,並在更動的時候 Email 一份 diff 給指定的電子郵件參考。預設 diff 是列出更動過的檔案,也可以要求 metche 顯示所有的修改細節。但是如果要求其顯示所有的修改內容,可能會誤把某些機要資訊像是密碼之類寄出來,為了避免資訊外漏,metche 也可以設定成寄出的信件使用 PGP 加密,只需要確定收件人的 PGP Key 在 root 的 keyring 中即可。

Continue reading

去年年中的時候架了一個 SmokePing 來監測某公司幾個服務的 Network Latency 問題,用 SmokePing 的原因是他支援數種協定,所以我可以一口氣拿來監測 DNS, SSH Daemon, RADIUS, Web, SMTP 等。而且 SmokePing 的架構頗模組化,只要稍加修改幾個 Perl Script 就可以很快的滿足我的需求。

不過既然已經隨時偵測網路服務,光是使用電子郵件通知也稍嫌不夠即時。於是起意做了簡訊通知功能,隨意找了幾個 SMS 服務供應商,決定拿便宜的 PCHOME 一元簡訊來頂著用。感謝 SnowFLY (飄然似雪) 做了 SMS PCHOMENet-SMS-PChome Perl module,省了不少功夫。也因此半夜時常被簡訊吵醒。

不過 CPAN 上的版本是 2006 年,跟目前的 PCHOME 網頁不太相容,稍加修改後如
Continue reading

Here is my little script for `incremental’ dump svn revision trees. The script just check every svn repositories which located at /home/svn, and save it in /home/backup by versions.

#!/bin/sh

for dir in /home/svn/* ; do
    name=$(basename ${dir})
    version=$(svnlook youngest ${dir})
    for ((r=1;r<${version};r++)) ; do
	if [ ! -f "/home/backup/${name}-$r.gz" ] ; then
		svnadmin dump ${dir} -r $r --incremental | \
			gzip -9> /home/backup/${name}-$r.gz
	fi
    done
done

Have fun! This is a tip.