網頁

顯示具有 FreeBSD 標籤的文章。 顯示所有文章
顯示具有 FreeBSD 標籤的文章。 顯示所有文章

2013年12月4日 星期三

FreeBSD console顯示中文

資料來源:http://www.wretch.cc/blog/iantsai/13572128

裝好 FreeBSD 後因為使用 SSH 或 Console 遠端登入,中文顯示會亂碼,所以必須要修改 LOCALE 設定,才能正常顯示出中文編碼。

2. 使用csh /etc/csh.cshrc 加入下面三行後重開機即可顯示中文。

#vi etc/csh.cshrc
setenv LC_CTYPE en_US.ISO8859-1
setenv LC_ALL zh_TW.UTF-8
setenv LANG zh_TW.UTF-8

3. 若使用 BASH ,則在 /etc/profile 中加入下面三行後重開機就可顯示中文。

LC_CTYPE=en_US.ISO8859-1 ; export LC_CTYPE
LC_ALL=zh_TW.UTF-8 ; export LC_ALL
LANG=zh_TW.UTF-8 ; export LANG

2013年11月26日 星期二

Pound HTTPS Configuration

轉貼自:http://www.project-open.org/en/howto_pound_https_configuration

Pound HTTPS Configuration

The following steps will guide you through the generation of a self-signed certificate for your ]project-open[ server.
During the process you will create:
  • server.key: This is a 1024 bit random string ("private key") that uniquely identifies your server
  • server.csr: This is a "Certificate Signing Request" file. You can send this to a Certificate Authorities (CA), or sign it yourself.
  • server.crt: This is a "certificate" that certifies that server.key belongs to you.
  • server.pem: This is the file that Pound needs to work correctly. A PEM file is a bundle of a the "server.key" priviate key and a certificate.
  1. Generate an RSA private key for the server:
    openssl genrsa -out server.key 1024
  2. Remove the passphrase from the key. Please make sure that nobody will have access to this file except for you. Otherwise the security of your server is at risk:
    cp server.key server.key.org
    openssl rsa -in server.key.org -out server.key
  3. Create the Certificate Signing Request file, or CSR:
    openssl req -new -key server.key -out server.csr
    You will have to provide certain information for your CSR. Here are some sample values for ]project-open[:

    Country Name (2 letter code) [GB]: ES
    State or Province Name (full name) [Berkshire]: Catalonia
    Locality Name (eg, city) [Newbury]: Barcelona
    Organization Name (eg, company) [My Company Ltd]: Project Open Business Solutions S.L.
    Organizational Unit Name (eg, section) []:
    Common Name (eg, your name or your server's hostname) []: www.project-open.org
    Email Address []:webmaster@project-open.com
    A challenge password []:
    An optional company name []:
  4. Now you could go to some Certificate Authority in the Web (for example: http://www.instantssl.com/ currently offers free certificates for 90 days) and sign your key there. As a result, you will receive a "certificate" file that you can save as "server.crt".
  5. As an alternative you can sign the key yourself.
    The server.crt certificate will be technically valid. However, your browser will show a security warning if it encounters such a self-signed certificate:
    openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
  6. Verify your certificat. The following command should output some data, and not an error message:
    openssl x509 -in server.crt -text
  7. Create a PEM file:
    openssl x509 -in server.crt -out server.pem
    openssl rsa -in server.key >> server.pem
    ­
  8. Now you can add a HTTPS listener configuration to your pound.cfg configuration file:
    ListenHTTPS
      Address 0.0.0.0
      Port    443
      Cert    "/etc/pound/server.pem"
    End

    Older versions of Pound (<2.2) may require a different listener configuration, please consult the man-page of your installed version of Pound.
The new configuration will be come active after restarting Pound (/etc/init.d/pound restart).
You can execute "netstat -nlp" to list all network connections. In the upper part your should see something like this:
...
tcp        0      0 0.0.0.0:8000                0.0.0.0:*                   LISTEN      24804/nsd
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      375/pound
...
tcp        0      0 0.0.0.0:443                 0.0.0.0:*                   LISTEN      375/pound
...­
  • ­ 0.0.0.0:8000: This is the AOLserver itself
  • 0.0.0.0:80: This is Pound listening for unincrypted HTTP connections
  • 0.0.0.0.443: This is the Pound HTTPS listener.
Pound will write any errors into /var/log/messages.

2013年4月26日 星期五

Copy a file to multiple directory.

Copy a file to multiple folder. Can use find command and type directory (-type d). 
Then use -exec run cp command copy to target {}.

e.g.
find . -name "folder_name" -type d -exec cp /xxx/filename.txt {} \;

2011年12月22日 星期四

FreeBSD IP Alias: Setup 2 or More IP address on One NIC

Set ip alias using ifconfig command line utility

Login as the root user.

Now, use ifconfig command as follows to set alias:
# ifconfig lnc0 192.168.1.5 netmask 255.255.255.255 alias
Persistent IP Alias Configuration

Edit file /etc/rc.conf to setup persistent ip aliasing option by appending following configuration, so that next time FreeBSD comes up (after restart/shutdown) it will create alias for you:
ifconfig_lnc0_alias0="192.168.1.5 netmask 255.255.255.255"

Finally, Restart FreeBSD network service using network restart script:
# /etc/rc.d/netif restart && /etc/rc.d/routing restart
Display alias and real ip using ifconfig lnc0 command:
# ifconfig lnc0

2011年12月21日 星期三

Subversion on NFS

svn repos置放於NFS上時所造成的問題,當commit時發生錯誤,如下:

svn: Commit failed (details follow):
svn: Can't get exclusive lock on file '/storage/openfoundry/repos/ntoutest/db/txn-current-lock': Operation not supported

處理方式
/etc/rc.conf 加入以下三行,重新啟動系統

nfs_client_enable="YES"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"

FreeBSD主機校時與時區設定

主機校時設定:

開機時,就校時乙次:
在 /etc/rc.conf 中加入:
ntpdate_enable="YES"
ntpdate_flags="clock.stdtime.gov.tw"

開機後,定時校時:
crontab 簡介:
在 /etc/periodic/ 資料夾中有三個目錄:

drwxr-xr-x 2 root wheel 1024 10 Giu 21:34 daily
drwxr-xr-x 2 root wheel 512 10 Giu 21:34 monthly
drwxr-xr-x 2 root wheel 512 10 Giu 21:34 weekly

而 /etc/crontab 中亦已定義每日、每週、每月定時分別執行各該目錄下的程序檔案。

我選擇每月定時校時:
編輯 /etc/periodic/monthly/190.ntpdate 檔,內容如下:
#!/bin/sh
echo
echo '主機校時:'
/usr/sbin/ntpdate clock.stdtime.gov.tw

chmod +x /etc/periodic/monthly/190.ntpdate

心血來潮時,手動校時。只有 root 才能做校時設定哦:
ntpdate clock.stdtime.gov.tw

2008年5月8日 星期四

用shell script 寫MLB 先發投手(Probable Pitchers)的查詢

想知道幾個有興趣的投手, 接下來幾天是否先發, 因此用sh去MLB的網頁查詢, 將五天內的先發資料找出來, 並寄信到自己的信箱, 每天就可以去看看這些投手的比賽狀況, 而不用每次在一堆資料中找出投手是否先發, 或是那一天先發, 實在是輕鬆了不少.
最大的目的, 是除了看王建民先發外, 也關心那些和王建民在爭投王的投手, 以及電玩人投手的情形.



2006年12月22日 星期五

會響的 PuTTY + screen + irssi

當PuTTY 視窗切到背景時,希望當關鍵字(例如自己的 ID )出現時,視窗就會發出通知,例如:閃爍或聲音。

1. irssi設定以下, 讓irssi發出訊號
/set beep_when_window_active ON
/set beep_when_away ON
/set beep_msg_level MSGS NOTICES DCC DCCMSGS HILIGHT
/set bell_beeps ON
2. ~/screenrc 裏加上vbell on或在screen裏按Ctrl-a Ctrl-g, 讓screen 會通知putty,
3. putty的settings->Terminal->Bell->Set the style of bell
可以選擇putty通知你的方式
 .選擇Visual Bell(Flash Window),讓Putty通知Windows閃爍.
 .選擇Play a custom sound file,可以發出聲音.

備註:

可用的beep_msg_level(設定樣什麼樣的訊息才要通知)如下:

CRAP, MSGS, PUBLIC, NOTICES, SNOTES, CTCPS, ACTIONS, JOINS, PARTS
QUITS, KICKS, MODES, TOPICS, WALLOPS, INVITES, NICKS, DCC, DCCMSGS,
CLIENTNOTICE, CLIENTCRAP, CLIENTERROR

And a few special ones that could be included with the levels above:
HILIGHT - text is highlighted
NOHILIGHT - don't check highlighting for this message
NO_ACT - don't trigger channel activity when printing this message
NEVER - never ignore or log this message (not a good idea usually)


參考資料
1.Jedi's BLOG http://jedi.org/blog/archives/003191.html
2.My_Beep Irssi-script http://www.xs4all.nl/~stacium/irssi/my_beep.html

更新時間 2007/06/07

2006年11月17日 星期五

irssi UTF-8 Big5 中文轉換與設定

這個Blog有詳細的說明, 簡述如下.


  • putty程式的Settings->Window->Translator設為UTF-8
  • 進screen的時候記得用screen -URD (U是使用UTF-8)
  • 進irssi後要設定
/SET term_charset UTF-8
/SET recode_transliterate ON
/SET recode_fallback UTF-8
/SET recode_out_default_charset UTF-8

/RECODE ADD #debian-zh UTF-8
/RECODE ADD #debian.tw Big5
/RECODE

irssi的設定檔存在 ~/.irssi/config

irssi 自動加入頻道

/network add OFTC(irc network)
/server add -auto -ircnet OFTC(irc network) irc.debian.org(server)
/channel add -auto #dot(channel) OFTC(irc network)

irssi命令

/server list: 列出Server
/channel list: 列出Channel
/win list: 列出視窗
/join #abc: 加入channel abc
/msg: Sends a message to a nick or a channel
/leave: 離開視窗
/quit: 離開irssi
/nick: 改名字
Alt + 數字: 切換視窗
Ctrl + n: 下一個視窗

/channel add -auto #ossf-bugteam IRCnet
/channel add -auto #elixus IRCnet
/channel add -auto #ossf IRCnet
/channel add -auto #perl.tw IRCnet
/channel add -auto #bsdchat IRCnet