Notes: November 2004 Archives

Gaim buddy icon

user-pic
Vote 0 Votes

Gaim 的個人大頭貼已在 1.0.1 版支援, 只是設定的地方不明顯, 到今天才發現!
工具 / 帳號清單 / 選擇MSN帳號 / 修改 / 好友圖示

ref. Gaim ChangeLog

在 FreeBSD 下用 root 直接跑下面的指令(已和 host 建好 authorized_keys)
rsync -avz -e ssh host:/remotedir /localdir
正常

放到 crontab 使用 root 執行, 卻會出現如下錯誤
WARNING: RSA key found for host somehost.com
in /root/.ssh/known_hosts:16
RSA key fingerprint 12:34:56:78:90:92:02:5d:e5:bb:9b:c2:0e:cb:00:ff.
Host key verification failed.
rsync: connection unexpectedly closed (0 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(348)

查了許久, 終於找到答案: console 下用的 ssh 和 crontab 下用的 ssh 不一樣

由於我有另外裝 OpenSSH
在 console 下 /usr/local/bin 的 path 排前面, 使用 /usr/local/bin
crontab 下 /usr/local/bin 的 path 排前面, 使用 /usr/bin
在我的環境下
freebsd 內建的 /usr/bin/ssh 會使用 DSA key fingerprint
OpenSSH 會使用 /usr/local/bin/ssh 會使用 RSA key fingerprint
所以才會產生 Host key verification failed. 的問題

awstats

user-pic
Vote 0 Votes

許久之前有用過這套, 今天又裝來玩玩, 功能已經變得滿強的了, 還有多國語系
安裝也很容易.
參照 安裝說明 , 手動或用 awstats_configure.pl 改好, 再把更新的指令加入 crontab 即可

pank.org awstats

Blog comment spam fighting

user-pic
Vote 0 Votes

這兩個 MT plugin 不錯
bayesian 用 bayesian 的方式訓練, 使 MT 能識別 comment spam
scode 在 post comment 時, 會出現一張被干擾的數字圖片, 必須輸入輸入裡面的數字才能 post

剛裝了 bayesian plugin, 步驟如下面的 script
最後再用 http://your.host/path_to_mt/bayesian-init-db.cgi 設定一下即可, 設完後刪除 bayesian-init-db.cgi
使用 http://your.blog.com/path_to_mt/mt-bayesian.cgi 來 train MT

#!/bin/sh
MTDIR=/home/pank/public_html/mt
cp mt-bayesian.cgi bayesian-init-db.cgi cleandb* $MTDIR
cp mt-bayesian.pl $MTDIR/plugins
cp Bayesian.pm BayesianBlog.pm BayesianToken.pm $MTDIR/lib/MT
cp BayesianTrain.pm $MTDIR/lib/MT/App
cp bayesian_menu.tmpl bayesian_list_blog.tmpl bayesian_list_comments.tmpl bayesian_list_pings.tmpl $MTDIR/tmpl/cms

ref.
http://mt-plugins.org/

sed edit files in place

user-pic
Vote 0 Votes

sed -i s/aaa/bbb/ file
=
perl -pi -e s/aaa/bbb file

backup as .bak
sed -i.bak s/aaa/bbb/ file

PS.
-i [suffix] is wrong under Linux (space not allowed between -i and [suffix])
sed in Solaris not support this parameter

samba 3.x charset

user-pic
Vote 0 Votes

samba 3.x default charset=utf-8
add following settings to smb.conf to change charset to big5
display charset = big5
unix charset = big5
dos charset = big5

man page to ps or pdf file

user-pic
Vote 0 Votes

man -t bash > bash.ps
man -t bash | ps2pdf - bash.pdf

ref.
-t Use /usr/bin/groff -Tps -mandoc -c to format the manual page,
passing the output to stdout. The output from /usr/bin/groff
-Tps -mandoc -c may need to be passed through some filter or
another before being printed.

PXE Server

user-pic
Vote 0 Votes

只要使用 dhcp server 及 tftp server, 就可以架 PXE Server
環境: pxelinux.0(from the SYSLINUX distribution), kernel, initrd file, image 等檔案放在 /tftpboot, tftp server 目錄指向這裡

使用 dhcp 3.0, dhcp.conf 範例

ddns-update-style none;
default-lease-time 86400;
max-lease-time 86400;

subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.11 192.168.1.50;
filename "pxelinux.0";
next-server 192.168.1.233;
option time-offset 3600;
option routers 192.168.1.1;
option domain-name-servers 192.168.1.253,168.95.1.1;
option domain-name "i";
}


若沒有指定 next-server, 會以 option routers 當作 tftp server

使用 udhcp 0.98, udhcpd.conf 範例

start 10.1.1.10
end 10.1.10.254
interface eth0
lease_file /var/dhcpd/udhcpd.leases
option dns 168.95.1.1 139.175.55.244
option subnet 255.255.0.0
option router 10.1.1.1
option lease 600
siaddr 10.1.1.1
boot_file pxelinux.0

使用 inetd, /etc/ined.conf 範例

tftp dgram tcp wait root /usr/sbin/tftpd tftpd -s /tftpboot

使用 xinetd, /etc/xinetd.d/tftp 範例

service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}

/tftpboot/pxelinux.cfg/default 範例

default dos
timeout 50
prompt 2

label linux
kernel systemk
append initrd=systemz ramdisk_size=65535 root=/dev/ram0

label dos
kernel memdisk
append initrd=psetup.img

ref.
PXE Spec
PXE daemon
http://phorum.study-area.org/viewtopic.php?t=19192

Replace files in msi package

user-pic
Vote 0 Votes

我不曉得有什麼好用的工具可以做到類似的動作,
以下的例子算是土法煉鋼 (以 MSN 7.0.0425 為例)

執行 Install_MSN_Messenger.exe, 在 %TEMP% 目錄可找到 msi 檔,
copy 出來成 msn7.0.0425.msi

然後用 msi2xml 轉換成 xml 檔

msi2xml msn7.0.0425.msi (在 windows 下執行)
會產生 msn7.0.0425.xml

傳到 linux 下, 使用 base64 來解檔

MSN 的檔案大都存在 MsgrCore.cab 裡

tail +$((`grep -n MsgrCore.cab msn7.0.0425.xml | tail -1 | cut -d: -f1`+2)) msn7.0.0425.xml > MsgrCore.cab.b64
抽出 MsgrCore.cab 的 base64 編碼部分, 存到 MsgrCore.cab.b64

base64 -d MsgrCore.cab.b64 MsgrCore.cab
將 MsgrCore.cab 解出

找一套能處理 cab 的壓縮程式, 例如 zipzag,
將修正過的 msnmsgr.exe 及中文化的 msgslang.dll (由 March Fun 製作),
覆蓋裡面的
msnmsgrexe.ADEB440D_7847_4F65_80BD_899870ED2EC9
msgslangdll.ADEB440D_7847_4F65_80BD_899870ED2EC9
(不清楚為什麼是這種檔名)

接下來要把 msn7.0.0425.xml 後半的 MsgrCore.cab md5 及 base64 部分, 用新的取代
XML=msn7.0.0425.xml
NEWXML=msn7.0.0425cht.xml
CAB=MsgrCore.cab
NEWCAB=new.cab
N=`grep -n $CAB $XML | tail -1 | cut -d: -f1`
head -$N $XML > $NEWXML
let N++
OLDMD5=`sed -n "$N"p $XML | cut -d\" -f4`
NEWMD5=`md5sum $NEWCAB | cut -d' ' -f1`
sed -n "$N"p $XML | sed s/$OLDMD5/$NEWMD5/ >> $NEWXML
mimencode $NEWCAB >> $NEWXML
tail -4 $XML >> $NEWXML

上面這段 script 會產生新的 xml 檔, 再回到 windows 用 xml2msi 轉
xml2msi msn7.0.0425cht.xml

最後產生 msn7.0.0425cht.msi, 直接安裝就是中文版!

簡單地說, 先用 msi2xml 轉成 xml 檔, 再把裡面檔案的 md5 及 base64 編碼部分置換,
再用 xml2msi, 轉回 msi 檔

77delegate

user-pic
Vote 0 Votes

http://ftp.77bbs.com/bbs/77delegate.exe

  • 程式功能: 提供 TCP relay 方式連線至 77bbs.com (我架的 BBS)
  • 使用時機: A 電腦無法連到 77, 但是可以連到 B 電腦
    B 電腦可以連到 77, 在 B 電腦裝 77delegate,
    A 電腦就可以 telnet B 電腦, 透過 B 電腦連上 77
  • 安裝: 直接執行即可, 安裝後會成為系統的一個服務, 若要停止該服務,
    可以到 控制台/系統管理工具/服務 裡面設定
  • 注意事項: 若有使用防火牆, 需將 tcp port 23 打開或設為例外連接埠
  • 進階用法: 若要修改安裝參數, 請用 WinRAR 開啟 77delegate.exe,
    修改 註解 裡面的 Setup= 參數
    預設是 Setup=setup.bat 23 77bbs.com 23
    表示使用 port 23, 對應到 77bbs.com port 23
    例如: 某公司網路限制嚴苛, 只能看網頁, 此時找一台有 public IP 的電腦,
    (假設 IP 是 100.1.1.1)
    參數改成 Setup=setup.bat 80 77bbs.com 23, Save 後, 再安裝
    即可使用 telnet 100.1.1.1 80 的方式連上 77

    77delegate 是使用 delegate 8.10.2版, 再加以包裝設定而成

  • 有時利用晚上時間下載東西, 又不想讓電腦開整晚, 可以用 shutdown 來預約關機

    -i 顯示 GUI 介面,必須是第一個選項
    -l 登出 (不能和 -m 選項一起使用)
    -s 電腦關機
    -r 關機並重新啟動電腦
    -a 中止系統關機
    -m \\\\computername 從遠端進行關機/重新啟動/中止
    -t xx 將關機等候時間設定成 xx 秒
    -c "comment" 關機註解 (最多 127 個字元)
    -f 強制關閉執行中的應用程式,不顯示警告
    -d [u][p]:xx:yy 關機原因代碼

    範例:
    shutdown -s -t 3600 -f (一小時鐘後關機)
    shutdown -a (取消關機)

    ddcxinfo

    user-pic
    Vote 0 Votes

    ddcxinfo 或 ddcxinfos 這個工具可以列出顯示卡的一些 X 參數資訊, ModeLine 等

    KNOPPIX 裡有功能類似的程式, 參數更完整
    # ddcxinfo
    syntax: ddcxinfo [-hsync] [-vsync] [-modelines]
    # ddcxinfo-knoppix
    syntax: ddcxinfo-knoppix [-hsync] [-vsync] [-modelines] [-monitor] [-modes] [-firstmode 1024x768]

    GNUPG

    user-pic
    Vote 0 Votes

    GnuPG is a complete and free replacement for PGP

    一開始先要造公/私金鑰
    gpg --gen-key

    對文件加簽
    gpg --clearsign file.txt
    會產生 file.txt.asc
    範例: (Mandrake Linux Community ISO MD5)
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    1ea7433e24eb6a3d9491128708a8e0e3 Mandrakelinux-10.1-Community-Download-CD1.i586.iso
    5b66d05d03ed2830ce6d09a7e4930b24 Mandrakelinux-10.1-Community-Download-CD2.i586.iso
    4815820ca0ff6a5c91525363889bc7bb Mandrakelinux-10.1-Community-Download-CD3.i586.iso
    d41d8cd98f00b204e9800998ecf8427e Mandrakelinux-10.1-Community-Download.md5
    9bbc6e07fcfc75dfef935e8673d3a5b1 Mandrakelinux-10.1-Community-Download.md5.asc
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.3 (GNU/Linux)

    iD8DBQFBUaXK54mK4HB3H/MRAgwWAKC1UYRdMR1XDt19/tk850KDnRENKQCeO1k4
    hjWxIi4FZoc5h8df4Z4xKEk=
    =RFQ2
    -----END PGP SIGNATURE-----

    檢查已加簽文件
    gpg --verify test.asc
    gpg: 由 西元2004年11月10日 (週三) 10時19分38秒 CST 建立的簽章,使用 DSA 金鑰 ID A8C4CEBC
    gpg: 完好的簽章來自於 "Henry Pan "

    isc dhcp fixed-address

    user-pic
    Vote 0 Votes

    ISC DHCPD 的 IP pool (range) 並不會自動排除已 fixed-address 的 IP
    舉個例子:
    subnet 192.168.0.0 netmask 255.255.255.0 {
    range 192.168.0.10 192.168.0.200;
    option routers 192.168.0.1;
    option domain-name-servers 168.95.1.1,168.95.192.1;
    }
    host test { hardware ethernet 00:90:dc:02:45:88; fixed-address 192.168.0.10; }
    這就是有問題的設定, 有可能有其他電腦會佔了 192.168.0.10 這個 IP,
    而 00:90:dc:02:45:88 這台電腦就無法取得 IP.

    正確的做法應該要把固定 IP 區段畫開,
    如:
    192.168.0.10 ~ 192.168.0.20 為固定分配 IP
    192.168.0.21 ~ 192.168.0.200 為動態分配 IP
    subnet 192.168.0.0 netmask 255.255.255.0 {
    range 192.168.0.21 192.168.0.200;
    option routers 192.168.0.1;
    option domain-name-servers 168.95.1.1,168.95.192.1;
    }
    host test { hardware ethernet 00:90:dc:02:45:88; fixed-address 192.168.0.10; }

    bash substitution

    user-pic
    Vote 0 Votes

    #!/bin/bash
    STRING=aaa.bbb
    echo ${STRING/bbb/ccc}

    result is aaa.ccc

    Workaround

    user-pic
    Vote 0 Votes

    這個字在大部分的字典都查不到, 但是在技術文件滿常見的.
    我是查了 Google 網上論壇 workaround group:tw.bbs.lang.english 得到結果, 整理如下:

    中文解釋

  • 雖不能根本解決, 但能避開問題的替代方法。
  • 避免問題或困難而旁道而行達到目的。
  • 權宜之計; 應急之策。
  • 原本是電腦術語, 相對於「Fix」而言. 當一個程式有了問題, 找出問題所在然後直接解決它叫做「Fix」; 當問題始終無法解決, 於是想個方法忽略這個問題並使這個問題不致於影響你要用這程式達到的目的, 這樣的方法就叫 Workaround。

    英文解釋

  • workaround means a manner of bypassing a problem caused by a bug without correcting the bug itself.
  • workaround is similar to "stopgap solution". If there is a problem, a "workaround" doesn't eliminate the problem, but it does bypass the problem.

    ref.
    http://en.wikipedia.org/wiki/Workaround
    http://whatis.techtarget.com/definition/0,,sid9_gci868091,00.html

    2006-07-17 Update: 把上述中文解釋加到中文維基百科

  • Resize Image

    user-pic
    Vote 0 Votes

    Use ImageMagick (this way keep EXIF data)

    convert DSCN0001.JPG -resize 800x600 small.jpg

    Use netpbm (this way lose EXIF data)

    jpegtopnm DSCN0001.JPG | pnmscale -width=800 -height=600 | pnmtojpeg > small.jpg

    ref. EXIF

    About this Archive

    This page is an archive of entries in the Notes category from November 2004.

    Notes: October 2004 is the previous archive.

    Notes: December 2004 is the next archive.

    Find recent content on the main index or look in the archives to find all content.

    Monthly Archives