月度归档:2010年04月

重新在Debian下编译mldonkey(LS_Pro)

出掉了LS1,只好把LS Pro拿出来当下载机了。

LS Pro是V1版,现成的Custom_uboot
是for V2的,硬件有少许的不同,启动时V1的硬盘参数是1:1,V2的参数是0:1,需要修改默认的UBoot env vars,我修改以后还是不能引导,一怒之下刷回stock_uboot。

其实仔细想下不一定非要刷Custom_uboot才可以运行Foonas_EM_Kernel,用stock_uboot同样可以实现一个危机处理系统。

在stock_uboot下进入官方的EM模式,用java程序 ACP Commander
清空root密码,以root权限telnet进去,即可用fdisk分区,然后插上U盘,将备份的系统文件分别解压在对应的dev/sda,dev/sdb即可。

最大的好处是可以自由分配系统空间大小,后续安装软件再也不怕空间不足了!另外系统出问题不用拆机取硬盘,直接在EM模式下搞定。

现在已经安装了debian,运行mldonkey正常,偷个懒把之前的mldonkey配置文件替换进去,发现不能启动了,一直在Resolving

还是以前的毛病,只有安装最新版的mldonkey才能解决。

正好有以前编译完成的文件夹备份,直接把文件夹复制到Lspro里面去,解包,make install,结果报错。无奈从头做起。

./configure之后提示zlib等一大堆库文件没有安装,看来得安装编译环境先。

apt-get install gcc g++ make libc6-dev
apt-get install libgd2-dev libmagic-dev zlib-dev bzip2-dev

发现源里面没有zlib-dev的安装包,只好自己下了个zlib-1.2.3.tar的源码包编译安装。

编译安装后继续./configure ,这下搞定了! 
Configuring MLDonkey 3.0.1 completed.

Network modules:
– eDonkey enabled (eMule SUI enabled)
– BitTorrent enabled
– FileTP (aka wget) enabled
– Fasttrack enabled
– Gnutella disabled – unmaintained
– Gnutella2 disabled – unmaintained
– Direct Connect disabled
– Open Napster disabled – currently not usable
– Soulseek disabled – currently not usable
– OpenFT disabled – currently not usable

Core features:
– zlib (required) enabled
– threads enabled
– bzip2 disabled
– iconv enabled
– libmagic disabled
– graphical stats disabled

Compilers:
– Ocaml version 3.11.1
– gcc version 4.1.2
– g++ version 4.1.2

Now execute ‘make’ to start compiling. Good luck!

To compile a static code execute: make mlnet.static
To produce a release tarball execute: make release.mlnet.static
To clean the build directory execute: make maintainerclean

Compiling CryptoPP.cc can take several minutes, on slow machines up to half an hour.
运行make报错!

想了一下,删除了之前编译的目录,重新去http://mldonkey.sourceforge.net/
下载代码,解压后执行./configure,这次提示 Checking Ocaml compiler.
——————————–
checking for ocamlc.opt… no
checking for ocamlc… no
checking for camlp4… no
******** Objective-Caml 3.11.1 is required *********
******* Check http://caml.inria.fr/ ********
Do you want this script to try to download and install ocaml
LOCALLY in mldonkey directory ?
当然选Y了!

又是漫长的过程,抓狂

点击查看原图

等待一个多小时,终于configure完毕。接着开始编译,幸好偶早有准备,在screen里面运行,省却N多烦恼事。

早上起来已经编译完了,开始make install安装,大概花了30分钟,搞定。 

点击查看原图

五一前的絮絮叨叨

清明刚过,五一就跟着来了。

今年的五一沾了世博的喜气,偶所在的民营企业也彻底响应了一次国家政策,让俺实实在在的高兴了一把。

前一段时间一直被HW的项目折磨着,手板机壳调试死活不达标,最后还是主管老大出手相救得以顺利搞定,否则丢了这个项目客户发飙老大更要发飙,后果不是一般的严重。

不知不觉暗室灯泡居然四个全挂了,黑咕隆咚白天换机器都忒不方便,估计晚上测试那哥们更得郁闷了。ETS总是一副不紧不慢的态度,我的要求并不高,五一前能把这事搞定就谢天谢地。

有帖子说6月13号河南新乡地震。沧海桑田世事无常,当年我念书的城市啊,居然就要地震了!不过立马有地震局专家出来辟谣,说越是预报得精确越是不可信;一边是民间预报一边是Z.F辟谣,党国威信尽丧,能怪谁。

博客访问速度是越来越慢了,编辑下日志得等半天。搞不明白这个米国主机到底是怎么回事,又没被墙又没当机延迟N高,不是看在不用备案的份上早就换空间了。

五一行程未定。

时间不早,且去睡觉。

转俩图,武汉 4月24号拍摄

点击查看原图
点击查看原图

phpdisk上传文件大小限制

在/etc/php5/cgi/php.ini中,设置post_max_size(表单最大值)和upload_max_filesize(单个文件最大值),上传文件的大小取决于两者中的最小值。

设置完毕后重启http服务:/etc/init.d/lighttpd force-reload

over

P.S:在网盘的首页设置里面不能使用英文的’字符,否则立马出现数据库查询错误
Parse error: syntax error, unexpected T_STRING, expecting ‘)’ in /netdisk/system/settings.inc.php on line 42

xauth: (stdin):1: bad display name “LSPPC-Lenny:1” in “add” command

启动vnc4server之后出现如下错误提示:LSPPC-Lenny:~# vnc4server
xauth: (stdin):1: bad display name "LSPPC-Lenny:1" in "add" command

New ‘LSPPC-Lenny:1 (root)’ desktop is LSPPC-Lenny:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/LSPPC-Lenny:1.log

可以正常进入X界面,但是xauth: (stdin):1: bad display name "LSPPC-Lenny:1" in "add" command总归让人不爽,研究一下怎么去除。

查了一下资料,发现跟网络配置有关系,在webmin的"网络配置"里选择"主机地址",然后添加主机名为LSPPC-Lenny,IP地址为127.0.0.1,确定保存,搞定。

点击查看原图点击查看原图

看了一下etc目录,下面生成一个hosts文件,里面内容如下图所示: 
 

点击查看原图

其实只要在etc下面新建一个hosts的文件,里面内容为127.0.0.1     LSPPC-Lenny就可以了。

 

X Windows on Linkstation(Gnome)

在终端机上成功搞定VNC连接X界面之后,打算尝试在NAS上也安装X界面,这样折腾起来就更爽啦!想着心里就倍儿高兴
NAS之前已经成功破解uboot并安装好2.6kernel的debian系统,现在要做的就是先安装好gnome需要的X组件。
apt-get install gdm gnome-core x-window-system-core ttf-arphic-uming
ttf-arphic-uming 是一个可以同时支持简繁体的免费字体,我暂且用它来使图形界面下的中文正常的显示。
喜欢KDE界面的可以这样安装:apt-get install kdm kde-core kde-i18n-zhcn x-window-system-core ttf-arphic-uming
偶习惯Gnome了,呵呵。
嗯,看了一下,需要下载260多MB的包,安装后大概占用800MB的硬盘空间,NAS的硬件不够强悍,看来这个过程需要等待N久了。

点击查看原图

等了N久终于完成下载过程,开始安装,过程也是漫长的,中间冒出一提示:
点击查看原图

不管它,继续下面安装过程。
等待啊等待,12点钟偶该睡觉了,解包安装过程还在持续,早点忘记开了screen来运行安装过程了,只好开着笔记本让它慢慢安装去。
早上醒来,发现已经安装完毕了!


白天要上班,晚上回来了继续折腾~~

下面该安装VNCserver了,这个过程也简单:apt-get install vnc4server
等待片刻,安装成功!
然后直接运行vnc4server,提示需要建立密码,按提示新建就可以了。
然后用VNC viewer连接我的NAS,顺利连接上去,不过却没有桌面,郁闷啊郁闷!

点击查看原图

看一下log,发现问题了:

点击查看原图

原因:vncserver默认寻找的X系统的字体路径在/usr/X11R6/lib/X11/fonts/下,而我的NAS貌似没有按这个默认路径存放fonts文件。
郁闷的是我也不知道NAS到底吧fonts文件丢哪里去了,不过不要紧,偶来找一下:
LSPPC-Lenny:~# find / -name fonts
/etc/X11/fonts
/etc/fonts
/mnt/webserver/discuz/uc_server/images/fonts
/mnt/webserver/discuz/images/fonts
/root/.gnome2/share/fonts
/usr/share/doc/console-data/fonts
/usr/share/X11/doc/fonts
/usr/share/fonts
/usr/share/xulrunner-1.9/res/fonts
/usr/lib/xorg/modules/fonts
/usr/local/share/fonts
欧了,/etc/X11/fonts就是fonts的路径了!


现在来做个链接搞定它:
LSPPC-Lenny:~# mkdir /usr/X11R6/lib
LSPPC-Lenny:~# cd /usr/X11R6/lib
LSPPC-Lenny:/usr/X11R6/lib# ls
LSPPC-Lenny:/usr/X11R6/lib# ln -s /etc/X11 X11
重新运行vnc4server,还是不能显示桌面!


突然想起NAS是没有显卡之类的硬件的,再安装个xserver-xorg-video-dummy试试:
LSPPC-Lenny:~# apt-get install xserver-xorg-video-dummy

再在.vnc/xstartup里面添加一行:gnome-session &

运行vnc4server,这次有进展了:

点击查看原图



嗯,好歹显示图形了,兴奋啊!要知道这可是NAS啊~
点了continue,NAS的硬件就是不行,等待半天,终于出现了偶朝思暮想的X界面,兴奋一下下!




点击查看原图

 看看表,不行,时间不早了,偶洗洗睡了,明天要上班的~
 

用VNC远程登陆ubuntu的X桌面

终端机装了ubuntu之后就一直在用putty+winscp远程登录ubuntu,用命令行来操作和配置Ubuntu系统。
不过老是感觉少了点什么,觉得图形界面也不错,尤其是在外面访问家里电脑的时候,这个想法更加强烈。

试了一下,可以用vnc4server来搭建VNC的服务器,客户端就用ultravnc,当然其他的VNC客户端也是可以地!ultravnc下载地址http://www.uvnc.com/download/1082/1082full.html

在ubuntu上安装vnc4server:sudo apt-get install vnc4server
安装完毕,先生成一个passwd文件:vnc4passwd
在$HOME/.vnc目录下面生成一个passwd文件,($HOME/.vnc是一个vnc4server的关键目录。)
开启vnc4server:vnc4server

会得到:desktop的名称,这个名称在客户端连接的时候用到。如果是desktop:1,在客户端连接的时候就填写:ip:5901,依此类推,如果是Desktop 2,在客户端的时候填写:ip:5902….
首次运行会提示生成了.vnc/xstartup文件,这个文件里面包含着登录启动X时的一下配置。

现在从UltraVNC登录,可能得到一个比较简单的窗口,因为VNC4Server缺省启动的WM是twm,如果希望启动gnome,需要改动.vnc/xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 1024×768+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &
这样登录的时候,会自动启动gnome
点击查看原图

Hardware performance of HP T5000 running under ubuntu

偶然跑到openwrt网站去逛逛,发现有个coubenchmark的项目,偶也来测试一下跑论坛的HP T5000的CPU性能。
源码在这里:http://cgit.openembedded.net/cgit.cgi?url=openembedded/commit/&id=f71735cf445f1ff3e3b464853f4f4303bf6f4078


#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>

#define VERSION_STR "v0.6"

// This is the overhead of calling gettimeofday() 2 times
double overhead = -1;

double begin_secs = 0;
double real_get_seconds() {
struct timeval tv;
double total;

gettimeofday(&tv, NULL);
total = (double)tv.tv_sec;
total += ((double)tv.tv_usec)/(double)1000000.0;

//printf("Secs: %d / Usecs: %d / FSecs: %f\n", tv.tv_sec, tv.tv_usec, total);

return total;
}

double get_seconds() {
if (begin_secs == 0) {
// First call
begin_secs = real_get_seconds();
}
return (real_get_seconds() – begin_secs);
}

double run_float_bench() {
double secs;
double begin = get_seconds();
int i;

double nb=0;
for (i=0;i<300000;i++) {
nb *= i;
int n = i >> 10;
nb /= n;
}

double end = get_seconds();
secs = end-begin;
printf("Time to run float bench: %.2f[secs]\n", secs);

return secs;
}

double do_run_memory_bench() {
double begin, end;
int i;
int* buf;
int len, index;
double secs;

begin = get_seconds();

len = (1<<21)/sizeof(int); // 2Mb
buf = malloc(len*sizeof(int));

// Write to memory – sequential
for (i=0;i<len;i++) {
buf[i] = i;
}

// Read memory – sequential
for (i=0;i<len;i++) {
int a = buf[i];
}

// Read memory – random
for (i=0;i<len;i++) {
index = (i*23)%(len/2);
int a = buf[index];
}

// Write memory – random
for (i=0;i<len;i++) {
index = (i*23)%(len/2);
buf[index] = i;
}
free(buf);

end = get_seconds();
secs = (end-begin);

return secs;
}

double run_memory_bench() {
double secs = 0;
int i;

for (i=0;i<10;i++) {
secs += do_run_memory_bench();
}

printf("Time to run memory bench: %.2f[secs]\n", secs);

return secs;
}

#define NBD 9009
double run_compute_e() {
double begin, end;
double secs;

begin = get_seconds();

int N=NBD, n=N, a[NBD],x;
while(–n) {
a[n]=1+1/n;
}

for(;N>9;) {
for(n=N–;–n; a[n]=x%n, x=10*a[n-1]+x/n) {
}
}

end = get_seconds();

secs = (end-begin);
printf("Time to run computation of e (%d digits): %.2f[secs]\n", NBD, secs);

return secs;
}

double run_compute_pi() {
double begin, end;
double secs;
int i;

begin = get_seconds();
//printf("Begin: %f\n", begin);

for (i=0;i<10;i++) {
int a=10000,b=0,c=8400,d=0,e=0,f[8401],g=0;

//printf("i:%d\n", i);
for(;b-c;) {
f[b++]=a/5;
}

for(;d=0,g=c*2;c-=14,e=d%a) {
for(b=c;d+=f[b]*a,f[b]=d%–g,d/=g–,–b;d*=b) {
}
}
//printf("Mid: %lld\n", (get_seconds()-end));
}

end = get_seconds();
//printf("End: %f\n", end);

secs = (end-begin);
printf("Time to run computation of pi (2400 digits, 10 times): %.2f[secs]\n", secs);

return secs;
}

int main() {
printf("This is CPU and memory benchmark for OpenWRT "VERSION_STR". This will then take some time… (typically 30-60 seconds on a 200MHz computer)\n");

double begin = get_seconds();
double end = get_seconds();
overhead = (end-begin)*1000000;
printf("Overhead for getting time: %.0fus\n", overhead);

// Nb 1
double sec_mem = run_memory_bench();

// Nb 2
double sec_pi = run_compute_pi();

// Nb 3
double sec_e = run_compute_e();

// Nb 4
double sec_float = run_float_bench();

printf("Total time: %.1fs\n", (sec_mem+sec_e+sec_pi+sec_float));

time_t t = time(0);
struct tm ti;
localtime_r(&t, &ti);
printf("\nYou can copy/paste the following line in the wiki table at: http://wiki.openwrt.org/HardwarePerformance\n");
printf("|| %04d-%02d-%02d || ”Author” || %.1fs || %.1fs || %.1fs || %.1fs || " VERSION_STR " || ”OS” || ”DeviceModel” || ”CPU model” || ”CPU Frequency” || ”LinkToHwPage” ||\n", (ti.tm_year+1900), (ti.tm_mon+1), ti.tm_mday, sec_mem, sec_pi, sec_e, sec_float);

return 0;
}

 

用记事本把源码保存为c扩展名的文件,偶保存为openwrt_cpu_bench_v06.c。
编译需要gcc环境,没有的话就apt-get install gcc安装即可。
开始编译root@ubuntu-server:/mnt/hda/share# gcc -o cpubench openwrt_cpu_bench_v06.c
很快,一秒钟不到就搞定了,目录下已经生成cpubench文件了
很好,现在开始运行一下:
root@ubuntu-server:/mnt/hda/share# ./cpubench
This is CPU and memory benchmark for OpenWRT v0.6. This will then take some time… (typically 30-60 seconds on a 200MHz computer)
Overhead for getting time: 1us
Time to run memory bench: 2.27[secs]
Time to run computation of pi (2400 digits, 10 times): 2.84[secs]
Time to run computation of e (9009 digits): 4.01[secs]
Time to run float bench: 0.01[secs]
Total time: 9.1s
You can copy/paste the following line in the wiki table at: http://wiki.openwrt.org/HardwarePerformance
|| 2010-04-06 || ”Author” || 2.3s || 2.8s || 4.0s || 0.0s || v0.6 || ”OS” || ”DeviceModel” || ”CPU model” || ”CPU Frequency” || ”LinkToHwPage” ||

用quixplorer搭建简练的web文件服务器

有时候需要给朋友共享一些文件,开FTP的话比较麻烦,想找个基于web界面的文件服务器,类似下面这样的最好不过了,可是已经装了lightttpd跑论坛,不想再为共享文件专门再装apache了。

点击查看原图

找了N久,发现一个叫quixplorer的东东不错,支持php环境,最重要的是短小精悍,下载下来的压缩包才60KB,跟nginx有一拼。
 

点击查看原图

直接在论坛目录下面建一个文件夹,把quixplorer解压丢进去,试着访问一下,已经OK了。
 

点击查看原图

再修改一下配置文件conf.php:

set "home_dir" to your desired home folder (e.g. /home/you/htdocs)
and set "home_url" to the corresponding URL. (e.g. http://yoursite

)

搞定