XiZi's Blog

我想要的多屏幕操作

  1. 在两个屏幕底部都能显示任务栏,任务栏显示当前屏幕包含横向主窗口的程序图标。
  2. 在屏幕之间拖动时,任务栏图标也随之改变。
  3. 没发现有类似的软件。

PGP keyservers:

 哎,费了老大劲,ubuntu的keyserver(keyserver.ubuntu.com)怎么也连不上,搜索了好几,终于找到了。原来,有这么多的PGP key server。

 来源网址:http://www.pramberger.at/peter/services/keyserver/network/

 

修改Ubuntu本地编码,让你的播放器正常显示标题

Ubuntu默认安装的环境为zh_CN.utf8或者en_US.utf8,然而很多windows的文档还是以GB2312或GBK编码保存的,当你打开Window文件的时候,总是有各种问题,出现各种诡异的乱码。因此十分有必要在Ubuntu下生成GBK或GB2312的locale。并设置默认本地编码:

1.  修改/var/lib/locales/supported.d/local文件,在文件中添加如下代码:

    zh_CN.GBK GBK

    en_US.GBK GBK

    zh_CN.GB2312 GB2312

    en_US.GB2312 GB2312

 

2.  sudo dpkg-reconfigure --force locales

          然后在输出的结果中会出现

          zh_CN.GB2312 done

          zh_CN.GBK done

    en_US.GBK done

    en_US.GB2312 done

3. 修改默认配置文件 /etc/default/locale

         修改默认LANG="en_US.UTF8"为

         LANG="en_US.GBK"

        或者

        LANG="zh_CN.GBK"

4.   重启Gmone

 

sudo /etc/init.d/gdm restart
# 如果没启动那么 Ctrl+Alt+F1 登录进入命令行模式
sudo /etc/init.d/gdm start

 

 

Just a copy of How to Install OpenVPN with bridge mode

 

How to Install Openvpn

Background:

When I first decided to create my own server I ran down a list of elements I wanted. The first were obvious, web-server, and e-mail server. However I also realized that I have many games that I would enjoy playing with friends. These are older games that only allow multiplayer over local networks. A very secure and novel solution is to use OpenVPN to make the remote computers appear as though they are on the same local network. So I set out to implement this on my second computer. I used Ubuntu Dapper Drake server edition and then began the painstaking task of configuring all the components. However when I tried to configure OpenVPN the documentation on their web-site was lacking. It has been updated and is very good now (this was in March of 2006) but I wrote a guide to installing and configuring OpenVPN on Ubuntu Dapper Drake. I hope you find this interesting and beneficial.

Purpose:

The purpose of this document is to describe how to install OpenVPN server on an Ubuntu Linux system and have it utilize an Ethernet bridge to access your local network. Ethernet bridges essentially allow the operating system to treat multiple network interfaces as one combined port. When used with OpenVPN a bridge will allow you to easily connect external users to your internal network and have them receive all traffic as though they were locally connected. The alternative is to use OpenVPN with a route but that will not allow some forms of traffic through (such as multicast), multicast traffic is important to me as many games require multicast data.

What is needed:

  1. Linux System running Ubuntu (tutorial will work with any Linux install with a few modifications)
  2. Root access to the server
  3. External computer to test with

Scope:

This tutorial aims to instruct how to install and configure an OpenVPN server with internal network access via an Ethernet bridge. This tutorial does not explain how to install Linux and get the OS environment configured. There are many good tutorials out there that you can use, once you have your Linux server ready simply follow this document.

If you are interested in a tutorial to configure your system I recommend this easy to follow guide:

http://www.howtoforge.com/perfect_setup_ubuntu_6.06

Tutorial:

1. The first thing you should do when installing OpenVPN is to read some of the documentation on the OpenVPN web-site. This seems like a simple step to skip but if you do not know exactly how OpenVPN works then you risk opening your internal network to security problems. Additionally there is a lot of good documentation on the OpenVPN site that will help you understand networking terms and methods. Such as exactly what an Ethernet Bridge is and how it differs from a route.

			# Link to OpenVPN Homepage         
			http://openvpn.net/          
			# Link to Explanation of bridging         
			http://openvpn.net/bridge.html	 
			

2. Now that you have taken some time to understand OpenVPN and Bridges we can begin to implement these technologies into a server on your local network. The first step is to collect information about your network, this tutorial is designed for a network that meets the following:

			Linux Server Internal IP: 173.23.1.5 	
			Internet Gateway: 173.23.1.1 	
			Gateway's IP Address: 139.142.227.155  	
			Network Layout: 	Internet ----- Router/Firewall ----- OpenVPN Server (eth1) 
			

3. To simplify setup for users you should register your IP address with an Internet Domain service. If you are cheap like me simply use "no-ip.com". Create an account then download their dynamic dns update tool and follow their installation instructions. This will give you a free dynamic domain. Additionally the IP address for your server needs to be static, this is due to the fact that the bridge will not update on a DHCP IP address change. You can configure this in your /etc/network/interfaces file. My server has an entry for my network card that looks like this:

			# The primary network interface
			# connects to insecure router
			auto eth0
			iface eth0 inet static
			address 173.23.1.5
			netmask 255.255.255.0
			network 173.23.1.0
			broadcast 173.23.1.255
			gateway 173.23.1.1
			# dns-* options are implemented by the resolvconf package, if installed
			dns-nameservers 142.165.200.5
			

4. Now that the information is collected you can begin by installing OpenVPN and the utilities to manage a bridge, to do this simply type:

			sudo apt-get install openvpn bridge-utils 
			

5. With OpenVPN installed we can now begin to configure, the first step is to move the apt-get directory into /etc/openvpn for easy access, and to preserve the original data (in case you mess up and need to revert).

			 cp -R /usr/share/doc/openvpn/examples/ /etc/openvpn/
			

6. Now we want to load the vars file with our own defaults. Open the file in your favorite editor and change KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG, and KEY_EMAIL to match your information.

			cd /etc/openvpn/examples/easy-rsa/ 	
			vi ./vars 	 
			

My vars file looks like this: (key components only)

			#this is to ensure secure data
			export KEY_SIZE=2048
			# These are the default values for fields
			# which will be placed in the certificate.
			# Don't leave any of these fields blank.
			export KEY_COUNTRY=CA
			export KEY_PROVINCE=SK
			export KEY_CITY=Martensville
			export KEY_ORG="TheBakershome"
			export KEY_EMAIL="geoff@thebakershome.net"
			

7. Now we to begin the configuration of the server.

			. ./vars 	
			./clean-all 	
			./build-ca 
			

The purpose of these command are as follows, the first one will clear any old keys or configuration elements, there should not be any there but it does not hurt to be sure. The last command will setup OpenVPN configuration items, be sure to follow the prompt and make sure you fill in using elements to match your situation. Since we loaded the vars file with your settings prior to these steps the default values should work on almost all elements, but the Common Name will need to be specified.

8. Now you need to create the server keys, these are private files that you should keep secure.

			./build-key-server server 
			
I found that if I did not use the same information that I used in the build-ca step above that the "Sign Certificate" and "commit" did not work. If you experience this problem just repeat this step with the same values, it should work at that point. This should not occur for you as we have loaded the default values into the vars file, but just in case be aware of the cause.

9. Now you are ready to generate keys for users, first decide if you wish to password protect the keys or not. I recommend building with passwords if you are not going to implement authentication in OpenVPN, if you are then simply generate without. This tutorial will assume that you are going to implement authentication in OpenVPN, since it is the most trusted method. Make sure that you specify the correct Common Name when prompted.

			#Generate with password 	  
			./build-key-pass username  	
			#Generate without password 	  
			./build-key username 
			

10. Now you need to build the Diffie Hellman parameters, for details on what these are simply check the OpenVPN homepage. The simple answer is that they provide a method to negotiate a secure connection over an insecure channel. This process will take a bit of time so you may want to take a break, just relax we are almost there.

			./build-dh 
			#generate server id key
			openvpn --genkey --secret ta.key
			

11. As an aside I found a very interesting table on the OpenVPN web-page. It provides some information on what to do with the various files we just generated. For the purposes of this tutorial I have "borrowed" their table and pasted it here, to view the original visit the OpenVPN installation guide on their homepage.

Filename Needed By Purpose Secret
ca.crt server + all clients Root CA certificate NO
ca.key key signing machine only Root CA key YES
dh{n}.pem server only Diffie Hellman parameters NO
server.crt server only Server Certificate NO
server.key server only Server Key YES
ta.key server+ all clients Server TLS Auth Key YES
client1.crt client1 only Client1 Certificate NO
client1.key client1 only Client1 Key YES
client2.crt client2 only Client2 Certificate NO
client2.key client2 only Client2 Key YES
client3.crt client3 only Client3 Certificate NO
client3.key client3 only Client3 Key YES
 

12. Now we need to configure the server.conf file to setup the operation. Here is my configuration file:

			# Which local IP address should OpenVPN 
			# listen on? (optional) 
			local 173.23.1.5 
			port 1194
			# TCP or UDP server? 
			proto udp 
			#This is key to configuring our bridge 
			dev tap0 
			#direct these to your generated files 
			ca /etc/openvpn/openvpn/examples/easy-rsa/keys/ca.crt 
			cert /etc/openvpn/openvpn/examples/easy-rsa/keys/server.crt 
			key /etc/openvpn/openvpn/examples/easy-rsa/keys/server.key   
			dh /etc/openvpn/openvpn/examples/easy-rsa/keys/dh2048.pem 
			ifconfig-pool-persist ipp.txt 
			#ensure the range of ip addresses you use in the last  two arguments 
			# of this statement are not in use by  either the DHCP server or any other
			# device on your  internal network. 
			server-bridge 173.23.1.5 255.255.255.0 173.23.1.60 173.23.1.70 
			#needed to allow communication to internal network 
			client-to-client 
			keepalive 10 120 
			#encryption - very important ;) 
			#AES encryption is backed by many security firms
			#however if you are concerned about speed use blowfish: "BF-CB"
			cipher AES-128-CBC  
			#if you have another subnet you need to provide the route
			push "route 173.23.2.0 255.255.255.0"
			#server id protection
			tls-auth ta.key 0
			#compression for network speed 
			comp-lzo 
			# if packets are too large fragment them (only really useful if you have an old router) 
			#fragment 1400 
			#limit the number of connections
			max-clients 5
			#some secuurity settings 
			# do not use if running server on Windows
			user nobody 
			group nogroup 
			persist-key 
			persist-tun 
			#log file settings 
			status openvpn-status.log 
			verb 3 
			# authentication plugin
			#forces client to have a linux acount in order to connect
			plugin /usr/lib/openvpn/openvpn-auth-pam.so login 
			

13. Now that the server is configured we need to create the bridge interface. The bridge is managed by Linux and is only used by OpenVPN so setup is a little different. I did it using a script to start/stop the interface. Place this script in "/etc/init.d/bridge" and then run the following:

			update-rc.d bridge defaults 15 
			

Here is the script, before using you will need to edit it for your network and server settings.

			#!/bin/bash  
			# Create global variables   
			# Define Bridge Interface 
			br="br0" 
			# Define list of TAP interfaces to be bridged, 
			# for example tap="tap0 tap1 tap2". 
			tap="tap0" 
			# Define physical ethernet interface to be bridged 
			# with TAP interface(s) above. 
			eth="eth0" 
			eth_ip="173.23.1.5" 
			eth_netmask="255.255.255.0" 
			eth_broadcast="173.23.1.255" 
			gw="173.23.1.1"   
			start_bridge () {   
			#################################   
			# Set up Ethernet bridge on Linux   
			# Requires: bridge-utils   
			#################################    
			for t in $tap; do
			openvpn --mktun --dev $t   
			done    
			for t in $tap; do
			ifconfig $t 0.0.0.0 promisc up   
			done
			ifconfig $eth 0.0.0.0 promisc up
			brctl addbr $br 
			brctl addif $br $eth
			for t in $tap; do
			brctl addif $br $t   
			done    
			ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast up   
			route add default gw $gw $br
			} 
			stop_bridge () {   
			####################################   
			# Tear Down Ethernet bridge on Linux   
			####################################    
			ifconfig $br down
			brctl delbr $br    
			for t in $tap; do
			openvpn --rmtun --dev $t   
			done   
			ifconfig $eth $eth_ip netmask $eth_netmask broadcast $eth_broadcast up   
			route add default gw $gw $eth
			}  
			case "$1" in 
			start)   
			echo -n "Starting Bridge"   
			start_bridge   
			;; 
			stop)   
			echo -n "Stopping Bridge"   
			stop_bridge   
			;; 
			restart)   
			stop_bridge   
			sleep 2   
			start_bridge   
			;; 
			*)   
			echo "Usage: $0 {start|stop|restart}" >&2   
			exit 1   
			;; 
			esac  
			

14. Now you need to edit your client configuration script, client.conf. This will be given to your clients and will be the script they invoke (via openvpn) to connect to your server. In the same way you modified the server.conf file edit the network information to match your internal network. Here is an example of one of my scripts:

			client 
			dev tap 
			proto udp 
			# change this to your server's address 
			remote thebakers.no-ip.org 1194 
			resolv-retry infinite 
			nobind
			persist-key 
			persist-tun 
			# Point the key and crt files to  
			# the ones for this user 
			tls-client
			ca ca.crt 
			cert geoff.crt 
			key geoff.key 
			#ensure that we are talking to a server 
			ns-cert-type server
			#confirm we are talking to the correct server 
			tls-auth ta.key 1
			# Select a cryptographic cipher. 
			# If the cipher option is used on the server 
			# then you must also specify it here. 
			cipher AES-128-CBC 
			# Enable compression on the VPN link. 
			comp-lzo 
			#fragment large packets 
			# I found I needed this for some games but it is 
			# not required
			#fragment 1400  
			# enable user/pass authentication
			auth-user-pass
			

15. Now you are ready to test your server, to do this load the server from the command line:

			sudo /etc/init.d/bridge start 	
			sudo openvpn /etc/openvpn/server.conf 
			

##Look for any errors that may be reported while OpenVPN parses the server.conf file. If it gets to the "Succeeded" state then switch computers to a PC on an external network (I used my PC at work) and open the OpenVPN connection. If everything is working here reboot your server and attempt to open the connection again, this will ensure that everything is booting correctly.

###Once the connection is established by the client test it by pinging devices on your internal network. Assuming everything is connected correctly you should be able to contact them.

16. If you have any troubles with step 16, the first place to look is at firewalls. If your server has firewall restrictions they may be blocking the bridge from operating, check your config and adjust as necessary. At this point your server should be running, good luck and have fun.

Post-Install

I ended up having some difficulty configuring shorewall on my openvpn server. It is a little tricky since you have to tell shorewall to differentiate between a physical input (eth0) and the virtual input (tap0). To do this open "/etc/shorewall/hosts" and add:

			net     br0:eth0
			vpn     br0:tap0
			

This will tell shorewall to differentiate between the vpn and the insecure traffic. Once you have this data you need to add the following to your policy file. This will tell shorewall that the traffic from the vpn is trusted so just let it all through.

				vpn     all     ACCEPT
				

You will also need to mention the vpn in the zones file by adding

				vpn     ipv4
				

Lastly you will need to tell shorewall that a tunnel is coming through by opening the tunnels file and adding:

				openvpn        net     0.0.0.0/0       vpn
				

Conclusion:

I hope your server is working good and that you can now play your old classic games with friends. The other benefit of this network is that you can access your data on your home PC from anywhere and you will be certain that your connection if free from intrusion.

英文界面Ubuntu,修改界面默认雅黑字体

原文出处:英文界面下的Ubuntu设置默认的中文字体

新浪博客:配置Ubuntu9.04雅黑字体

  1。对于默认使用中文字体的问题:

    用Ubuntu 的英文界面的朋友,进入系统后字体是Bitmap, 在evolution中收中文邮件时,新邮件里的中文乱码。
一定是字体出了问题,检查后发现在切换到英文界面后/etc/fonts/conf.d/中29-language-selector-zh.conf、 69-language-selector-zh-cn.conf、99-language-selector-zh.conf这三个链接被删掉了。
在/etc/fonts/conf.d 里面加上3 个文件的链接:

cd /etc/fonts/conf.d/
sudo ln -s /etc/fonts/conf.avail/29-language-selector-zh.conf
sudo ln -s /etc/fonts/conf.avail/69-language-selector-zh-cn.conf  //好像只要这个就行
sudo ln -s /etc/fonts/conf.avail/99-language-selector-zh.conf 


重启看看中文变成了系统默认的雅黑。

2。添加字体

        Ubuntu 9.04 正式版的默认字体感觉太粗,有点模糊。改为文泉译字体,英文又不漂亮,于是将其替换成了微软雅黑字体 Yahei Consolas Hybrid ,该字体包含了Lucida Grande.ttf 和 Microsoft YaHei.ttf,前者是英文等宽字体,后者是中文字体,使用这个字体就不用考虑单独设置中英文字体了,可以做到界面、网页、终端字体统一风格。

  另外经常要共享Office文档,基本都是使用宋体,仅有雅黑还不够,所以不得不把XP下的simsun等字体也拷贝一份过来。(用着D版XP就考虑不了字体版权问题了)

  配置过程:

  1)、拷贝XP字体:

 

  sudo mkdir -p /usr/share/fonts/zh_CN/TrueType
sudo cp /media/win_c/WINDOWS/Fonts/simsun.ttc /usr/share/fonts/zh_CN/TrueType/
sudo cp /media/win_c/WINDOWS/Fonts/tahomabd.ttf /usr/share/fonts/zh_CN/TrueType/
sudo cp /media/win_c/WINDOWS/Fonts/tahoma.ttf /usr/share/fonts/zh_CN/TrueType/
sudo cp /media/win_c/WINDOWS/Fonts/verdanab.ttf /usr/share/fonts/zh_CN/TrueType/
sudo cp /media/win_c/WINDOWS/Fonts/verdanai.ttf /usr/share/fonts/zh_CN/TrueType/
sudo cp /media/win_c/WINDOWS/Fonts/verdana.ttf /usr/share/fonts/zh_CN/TrueType/
sudo cp /media/win_c/WINDOWS/Fonts/verdanaz.ttf /usr/share/fonts/zh_CN/TrueType/

 

 

  2)、下载雅黑字体

  http://rapidshare.com/files/34563809/YaHei.Consolas.1.11b.zip

  解压后,复制到 /usr/share/fonts/zh_CN/TrueType 目录,并重命名为YaHei_Consolas.ttf:

  sudo cp YaHei.Consolas.1.11b.ttf /usr/share/fonts/zh_CN/TrueType/YaHei_Consolas.ttf

  3)、生成字体目录列表等命令:

  

    sudo chmod 644 /usr/share/fonts/zh_CN/TrueType/*

cd /usr/share/fonts/zh_CN/TrueType/

sudo mkfontscale

sudo mkfontdir

sudo fc-cache /usr/share/fonts/zh_CN/TrueType/

 

  4)、修改配置文件

  sudo gedit /etc/fonts/conf.d/69-language-selector-zh-cn.conf

  找到 行,添加 YaHei Consolas Hybrid (这个是字体的名字,不是字体的文件名,双击字体文件可以查看字体名)共有三处,都要添加

  例如:

  YaHei Consolas Hybrid

  Bitstream Vera Sans Mono

  DejaVu Sans Mono

  WenQuanYi Zen Hei

  AR PL UMing CN

  AR PL ShanHeiSun Uni

  WenQuanYi Bitmap Song

  AR PL UKai CN

  AR PL ZenKai Uni

  5)、重启x-window

  正常的话,在没重启x-window时就应该能看到效果,可以查看一下各软件菜单、网页内容、虚拟终端的字体应该都有变化了。另外打开Word文档,宋体也可以显示正常。

 

 

 

OpenFoam 1.6 编译

1.安装缺失的包

sudo apt-get install flex
sudo apt-get install binutils-dev
sudo apt-get install bison
sudo apt-get install libzip-dev

 

 

2.修正源文件

自己down一个mpfr-2.4.1.tar.gz,解压到ThirdParty-1.6目录下面对应的文件夹里,原文件夹好像缺少部分文件。

3.开始执行wmake

回到OpenFOAM-1.6目录执行        

 

cd $WM_PROJECT_DIR
./Allwmake

 

 

历时1天,终于搞定了OpenFOAM.给个总结吧!

1、错误是不可避免的,一定按照Readme来作,顺序不可以错。不要着急上一步还没弄完就急着下一步,往往会遇见不可理喻的错误。

2、对于paraView的编译是问题的关键,华处理要依赖于此,所以如果这个没编译好就编译PV3FoamReader模块,就会出现以下错误:

        cannot find -lpqComponents

如果你使用的是OpenFOAM默认的ThirdParty中的paraView(对于我的OpenFOAM1.5就是ParaView3.3-cvs),那么按照说明去编译你的PV3FoamReader吧,应该没问题了。还有问题?好看看你的环境变量吧:

 

env
#下面是我的结果: 主要注意红色的几个

WM_LINK_LANGUAGE=c++
MANPATH=
ORBIT_SOCKETDIR=/tmp/orbit-ado
FOAM_SOLVERS=/home/ado/OpenFOAM/OpenFOAM-1.5/applications/solvers
FOAM_APPBIN=/home/ado/OpenFOAM/OpenFOAM-1.5/applications/bin/linux64GccDPOpt
SSH_AGENT_PID=3746
FOAM_TUTORIALS=/home/ado/OpenFOAM/OpenFOAM-1.5/tutorials
FOAM_JOB_DIR=/home/ado/OpenFOAM/jobControl
WM_ARCH=linux64
GPG_AGENT_INFO=/tmp/seahorse-JyCvcj/S.gpg-agent:3869:1
WM_JAVAC_OPTION=Opt
TERM=xterm
SHELL=/bin/bash
MPI_ARCH_PATH=/home/ado/OpenFOAM/ThirdParty/openmpi-1.2.6/platforms/linux64GccDPOpt
FOAM_LIB=/home/ado/OpenFOAM/OpenFOAM-1.5/lib
WM_THIRD_PARTY_DIR=/home/ado/OpenFOAM/ThirdParty
XDG_SESSION_COOKIE=0cb345adacd15ab1d7f9e4c34a606381-1248739202.385802-1787204229
GTK_RC_FILES=/etc/gtk/gtkrc:/home/ado/.gtkrc-1.2-gnome2
WINDOWID=63494839
ParaView_INST_DIR=/home/ado/OpenFOAM/ThirdParty/ParaView3.6.1
FOAM_MPI_LIBBIN=/home/ado/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/openmpi-1.2.6
GTK_MODULES=canberra-gtk-module
FOAM_APP=/home/ado/OpenFOAM/OpenFOAM-1.5/applications
WM_CXXFLAGS=-m64 -fPIC
WM_CFLAGS=-m64 -fPIC
WM_PROJECT_VERSION=1.5
OPAL_PREFIX=/home/ado/OpenFOAM/ThirdParty/openmpi-1.2.6/platforms/linux64GccDPOpt
USER=ado
LD_LIBRARY_PATH=/home/ado/OpenFOAM/ThirdParty/ParaView3.6.1/platforms/linux64Gcc/bin:/home/ado/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/openmpi-1.2.6:/home/ado/OpenFOAM/ThirdParty/openmpi-1.2.6/platforms/linux64GccDPOpt/lib:/home/ado/OpenFOAM/ThirdParty/gcc-4.3.1/platforms/linux64/lib64:/home/ado/OpenFOAM/ThirdParty/gcc-4.3.1/platforms/linux64/lib:/home/ado/OpenFOAM/ado-1.5/lib/linux64GccDPOpt:/home/ado/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:
MPI_BUFFER_SIZE=20000000
WM_COMPILER_LIB_ARCH=64
FOAM_SRC=/home/ado/OpenFOAM/OpenFOAM-1.5/src
FOAM_SIGFPE=
ParaView_DIR=/home/ado/OpenFOAM/ThirdParty/ParaView3.6.1/platforms/linux64Gcc
WM_PROJECT_INST_DIR=/home/ado/OpenFOAM
FOAM_UTILITIES=/home/ado/OpenFOAM/OpenFOAM-1.5/applications/utilities
WM_CXX=g++
WM_PROJECT_DIR=/home/ado/OpenFOAM/OpenFOAM-1.5
GNOME_KEYRING_SOCKET=/tmp/keyring-6ttQQv/socket
SSH_AUTH_SOCK=/tmp/keyring-6ttQQv/socket.ssh
WM_COMPILER_ARCH=
SESSION_MANAGER=local/ado-Main:/tmp/.ICE-unix/3546
USERNAME=ado
CINTSYSDIR=/home/ado/pub/CINT/cint
WM_PROJECT=OpenFOAM
WM_LDFLAGS=-m64
WM_COMPILER=Gcc
WM_MPLIB=OPENMPI
DESKTOP_SESSION=default
PATH=/home/ado/OpenFOAM/ThirdParty/ParaView3.6.1/platforms/linux64Gcc/bin:/home/ado/OpenFOAM/ThirdParty/openmpi-1.2.6/platforms/linux64GccDPOpt/bin:/home/ado/OpenFOAM/ThirdParty/gcc-4.3.1/platforms/linux64/bin:/home/ado/OpenFOAM/ado-1.5/applications/bin/linux64GccDPOpt:/home/ado/OpenFOAM/OpenFOAM-1.5/applications/bin/linux64GccDPOpt:/home/ado/OpenFOAM/OpenFOAM-1.5/wmake:/home/ado/OpenFOAM/OpenFOAM-1.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/real/RealPlayer
FOAM_USER_LIBBIN=/home/ado/OpenFOAM/ado-1.5/lib/linux64GccDPOpt
QT_IM_MODULE=xim
WM_COMPILER_DIR=/home/ado/OpenFOAM/ThirdParty/gcc-4.3.1/platforms/linux64
GDM_XSERVER_LOCATION=local
WM_CC=gcc
PWD=/home/ado
XMODIFIERS=@im=SCIM
LANG=en_US.UTF-8
GNOME_KEYRING_PID=3532
GDM_LANG=en_US.UTF-8
PV_PLUGIN_PATH=/home/ado/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt
FOAM_INST_DIR=/home/ado/OpenFOAM
FOAM_LIBBIN=/home/ado/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt
WM_COMPILE_OPTION=Opt
GDMSESSION=default
HISTCONTROL=ignoreboth
ParaView_VERSION=3.6.1
WM_DIR=/home/ado/OpenFOAM/OpenFOAM-1.5/wmake
SHLVL=1
HOME=/home/ado
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
PYTHONPATH=/home/ado/OpenFOAM/ThirdParty/ParaView3.6.1/platforms/linux64Gcc/Utilities/VTKPythonWrapping
LOGNAME=ado
WM_PROJECT_USER_DIR=/home/ado/OpenFOAM/ado-1.5
FOAM_RUN=/home/ado/OpenFOAM/ado-1.5/run
XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-gxBh7E8bUq,guid=f696868c90a37644fe4f4b2d4a6e3f84
MPI_HOME=/home/ado/OpenFOAM/ThirdParty/openmpi-1.2.6
WM_OPTIONS=linux64GccDPOpt
LESSOPEN=| /usr/bin/lesspipe %s
WINDOWPATH=7
DISPLAY=:0.0
WM_PRECISION_OPTION=DP
GTK_IM_MODULE=scim-bridge
WM_ARCH_OPTION=64
WM_OS=Unix
LESSCLOSE=/usr/bin/lesspipe %s %s
FOAM_USER_APPBIN=/home/ado/OpenFOAM/ado-1.5/applications/bin/linux64GccDPOpt
XAUTHORITY=/home/ado/.Xauthority
COLORTERM=gnome-terminal
_=/usr/bin/env
 

 

 

这里我的就是安装的最新的ParaView3.6.1,不是安装的默认的。如果你装的也不是默认的那么可以修改这个文件实现自动配置以上环境变量:

 

gedit $WM_PROJECT_DIR/etc/apps/paraview3/bashrc

# 修改

export ParaView_VERSION="3.3-cvs"

# 为

ParaView_VERSION=<your paraview version> !对于我这里是 "3.6.1"
# 应该和ThirdParty中的paraView目录想对应。

 

 

 

好了,应该可以编译了。

3、对于默认编译paraView3.3-cvs是提示 “No Target“ 什么的错误,是因为你的QT不是4.3.x的版本,我的ubuntu9.04就是默认的QT4.5。想编译?方法就是把其目录下的CMakeLists.txt中对应的检查QT版本的给该了:

 

# 原代码 83开始
  # ParaView requires this minimum version of Qt, and let's do it here before
  # our first call to FindQt4.cmake
  SET(QT_MIN_VERSION "4.3.0")
  SET(QT_REQUIRED TRUE)
  FIND_PACKAGE(Qt4)
  IF(NOT QT4_FOUND)
    MESSAGE(SEND_ERROR "Qt ${QT_MIN_VERSION} or greater not found.  Please check the QT_QMAKE_EXECUTABLE variable.")
  ELSE(NOT QT4_FOUND)
    # don'
t go greater than supported version
    STRING(REGEX MATCH "^4\\.3\\.[0-9]+" qt_version_tmp "${QTVERSION}")  //注意改这一行
    IF (NOT qt_version_tmp)
      MESSAGE(SEND_ERROR "Qt ${QTVERSION} not supported.  Please use Qt 4.3 (you may need to clean your dirtied cache).")
    ENDIF (NOT qt_version_tmp)
    # enforce Carbon in VTK for Qt/Mac
    IF(Q_WS_MAC)
      SET(VTK_USE_CARBON ON CACHE BOOL "Build VTK with Carbon" FORCE)
      SET(VTK_USE_COCOA OFF CACHE BOOL "Build VTK with Cocoa" FORCE)
    ENDIF(Q_WS_MAC)
    # Mark these Qt variables as advanced. Users don't really have to set them.
    MARK_AS_ADVANCED(DESIRED_QT_VERSION VTK_USE_QVTK VTK_USE_GUISUPPORT)
    MARK_AS_ADVANCED(QT_MKSPECS_DIR QT_PLUGINS_DIR QT_X11_X11_LIBRARY QT_X11_Xext_LIBRARY QT_X11_m_LIBRARY)
  ENDIF(NOT QT4_FOUND)

# 修改为:
  # ParaView requires this minimum version of Qt, and let'
s do it here before
  # our first call to FindQt4.cmake
  SET(QT_MIN_VERSION "4.3.0")
  SET(QT_REQUIRED TRUE)
  FIND_PACKAGE(Qt4)
  IF(NOT QT4_FOUND)
    MESSAGE(SEND_ERROR "Qt ${QT_MIN_VERSION} or greater not found.  Please check the QT_QMAKE_EXECUTABLE variable.")
  ELSE(NOT QT4_FOUND)
    # don't go greater than supported version
    STRING(REGEX MATCH "^4\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}") 
//修该为这个样子
    IF (NOT qt_version_tmp)
      MESSAGE(SEND_ERROR "Qt ${QTVERSION} not supported.  Please use Qt 4.3 (you may need to clean your dirtied cache).")
    ENDIF (NOT qt_version_tmp)
    # enforce Carbon in VTK for Qt/Mac
    IF(Q_WS_MAC)
      SET(VTK_USE_CARBON ON CACHE BOOL "Build VTK with Carbon" FORCE)
      SET(VTK_USE_COCOA OFF CACHE BOOL "Build VTK with Cocoa" FORCE)
    ENDIF(Q_WS_MAC)
    # Mark these Qt variables as advanced. Users don'
t really have to set them.
    MARK_AS_ADVANCED(DESIRED_QT_VERSION VTK_USE_QVTK VTK_USE_GUISUPPORT)
    MARK_AS_ADVANCED(QT_MKSPECS_DIR QT_PLUGINS_DIR QT_X11_X11_LIBRARY QT_X11_Xext_LIBRARY QT_X11_m_LIBRARY)
  ENDIF(NOT QT4_FOUND)
 

应该差不多了。发现信问题再更新吧。

 

我的OpenFOAM第一步

基本上按照OpenFOAM的指导进行安装,但Ubuntu默认没有这几个库,得先手动装一下。

 

sudo apt-get install flex
sudo apt-get install binutils-dev

其他的还On the Way

还有就是确认你的ThirthParty目录里面有Gcc。没有的话,找一个方里面。我就是在OpenFOAM官方down的一个Bin包。

 

 

ubuntu 9.04 server pptpd vpn server 配置

This is a bug in Ubuntu 9.04 with pptpd you have to disable the logs in
/etc/pptpd.conf put a quote on logwtmp.

# TAG: logwtmp
#       Use wtmp(5) to record client connections and disconnections.
#
# logwtmp  //加一个#注释掉这行
 

重启pptpd服务

sudo /etc/init.d/pptpd restart

再次连接应该正常了。

Setup a VPN server in Ubuntu 8.10 for iPhone

Why still Intrepid (Ubuntu 8.10) server? I just don’t have time to upgrade it. For a server, as long as it is secure and stable, no need for the cutting edge.

Why VPN? Check wiki. For me, I want to access some location sensitive files while I am on the iPhone via 3G network.

How? There is an excellent How-To in Chinese. I followed it and it works! This post is a summary of what I did.

For iPhone, three VPN protocols are supported: L2TP, PPTP and Cisco IPSec. I am going to install a pptpd on my Ubuntu server.

  1. Get the server installed.
    sudo apt-get install pptpd
  2. Edit /etc/pptpd.conf file to setup the IP address for connected clients. Enable localip and remoteip to something like
    localip 10.100.113.1
    remoteip 10.100.113.2-4
  3. Use /etc/resolv.conf to find the DNS of the system, and edit /etc/ppp/pptpd-options to enable ms-dns - something like
    ms-dns 128.218.254.10
    ms-dns 128.218.254.40
  4. Set the VPN account by editing /etc/ppp/chap-secrets. For an account test with password TSET that can connect from any where
    test pptpd TSET *
  5. Restart the server by executing
    sudo /etc/init.d/pptpd restart
  6. Enable forward for Internet connection. First, edit /etc/sysctl.conf file to enable
    net.ipv4.ip_forward=1

    and

    sudo sysctl -p

    Second, use iptables (install by apt-get) to setup a route

    sudo iptables -t nat -A POSTROUTING -s 10.100.113.0/24 -o eth0 -j MASQUERADE
  7. Setup VPN in the iPhone by General > Network > VPN > PPTP. Enable Auto encryption level. Keep RSA SecurID off.
    iphone-vpn-pptp
    It should work now.
  8. Automatically enable iptables after rebooting. First, save the working iptables by
    # iptables-save > /etc/iptables-rules

    Second, edit /etc/network/interfaces to something like

    # The primary network interface
    auto eth0
    iface eth0 inet dhcp
    pre-up iptables-restore < /etc/iptables-rules
    

 

 That is all I did and I don’t need to tweak other things as listed in the original post. I also tested on a windows xp machine, which works like a charm. Enjoy Ubuntu!

PS:

这里添加一下在Centos6.4遇到防火墙(iptables及iptables6)的问题解决方法:(Added at 2013.4.11)

 

iptables -F FORWARD #允许转发,默认是禁止的
iptables -t nat -A POSTROUTING -j MASQUERADE #全网段可NAT,不安全。
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE #部分网段NAT,安全考虑可以使用这个命令。
iptables -A INPUT -i tun* -j ACCEPT #允许Tun*接口的所有传入连接
/etc/init.d/iptables save

ok,就这样应该就可以了。

 

 

 

 

 

 

修改pam_mysql的源代码,让他支持ipv6.

      配置了vsftp+pam_mysql+mysql的虚拟用户管理系统。但学校的ipv6网络,人家用ipv6访问的时候不能准确记录其ip地址。遂down了pam_mysql的源代码,改之。基于尽量少的改动原有文件的原则。添加了部分代码。现在ok了。下面给大家说说具体修改过程。

1.    当然是下载源代码了。

           在你能有写权限的目录,比如 /home/you/ 建立工作目录如:mysql-pam  并进入

mkdir pam-mysql
cd pam-mysql
apt-get source libpam-mysql

将会得到以下文件

ado@www:~/mysql-pam$ ls
pam-mysql-0.6.2            pam-mysql_0.6.2-1.dsc
pam-mysql_0.6.2-1.diff.gz  pam-mysql_0.6.2.orig.tar.gz
 

 2.    修改pam_mysql.c

ado@www:~/mysql-pam$ cd pam-mysql-0.6.2/
ado@www:~/mysql-pam/pam-mysql-0.6.2$ vim pam_mysql.c
 

 

第1753行,原文件为:

        if (NULL == (remote_host = xcalloc(16, sizeof(char)))) {
                syslog(LOG_AUTHPRIV | LOG_CRIT, PAM_MYSQL_LOG_PREFIX "allocation failure at " __FILE__ ":%d", __LINE__);
                return PAM_MYSQL_ERR_ALLOC;
        }
 

修改为:

        if (NULL == (remote_host = xcalloc(255, sizeof(char)))) {
                syslog(LOG_AUTHPRIV | LOG_CRIT, PAM_MYSQL_LOG_PREFIX "allocation failure at " __FILE__ ":%d", __LINE__);
                return PAM_MYSQL_ERR_ALLOC;
        }
 

 

给remote_host变量足够的存储空间。

 

从1752行开始田间如下能容:

                sprintf(remote_host,"%s","unknown");
                struct sockaddr_in6 client_address;
                int salen6=sizeof(client_address);
                 if (!getpeername(0, (struct sockaddr *) &client_address, &salen6))
                {
                        char inet[64]="no ip is 2001:0da8:a800:0000:0000:0000:0000:0000 has nothing to do";
                        inet_ntop(AF_INET6,&(client_address.sin6_addr),inet,strlen(inet));
                        sprintf(remote_host,"%s",inet);
                }
                //strcpy(remote_host, "(unknown)");注释掉原来的操作
               //下面的代码不变

3. 好了,重新编译吧

./configure  !如果提示找不到什么“mysql_config”就安装这个包"libmysqlclient15-dev"

make

sudo make install

# 默认会安装到 /usr/lib/security/里面。
# 建个软连接

ln -s /usr/lib/security/pam_mysql.so /lib/security/pam_mysql.so

 




Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee