Ads 468x60px

Pages

2010年8月13日 星期五

cfengine 3 的安裝與設定




Note: cfengine 3 is a revisional version, compare to cfengine 2.

Go to the website and dowload rpm (http://www.cfengine.org)

[root@host]#rpm -ivh ./cfengine-community-3.0.5-1.el5.x86_64.rpm

安裝完成後,請查看一下所安裝的檔案位置。

[root@h masterfiles]# rpm -ql cfengine-community
/etc/default/cfengine3
/etc/init.d/cfengine3
/usr/local/share
/usr/local/share/doc
/usr/local/share/doc/cfengine
/usr/local/share/doc/cfengine/ChangeLog
/usr/local/share/doc/cfengine/INSTALL
/usr/local/share/doc/cfengine/NEWS
/usr/local/share/doc/cfengine/README
/usr/local/share/doc/cfengine/cfengine_stdlib.cf
/usr/local/share/doc/cfengine/inputs
/usr/local/share/doc/cfengine/inputs/failsafe.cf
/usr/local/share/doc/cfengine/inputs/library.cf
/usr/local/share/doc/cfengine/inputs/promises.cf
/usr/local/share/doc/cfengine/inputs/site.cf
/usr/local/share/doc/cfengine/inputs/update.cf
/usr/local/share/doc/cfengine/promise_knowledge.cf
....

2010年8月12日 星期四

CentOS 5.x RHEL(RedHat Enterprise Linux) 5.x 安裝 Xen hypervisor 3.x 筆記



因為工作上的需求,要提供多份的 RHEL 5.x 環境給不同部門做測試用;因為是測試用,所以它所需的硬體資源也不會太多,於是乎想到來試試把它們都安裝到同一台主機上吧!要達成這個目的,非 Virtualization 莫屬。

因為是要提供 RHEL 5.x 的環境,Redhat 公司對於 Xen Hpyervisor 支援完整,所以就直接選定用它囉!

Xen 支援兩種不同的虛擬化模式:Para-virtualization(半虛擬化), Fully-virtualization(全虛擬化),以下是它們的簡短介紹。

  • Para-virtualization(半虛擬化)
    • 半虛擬化需使用特殊的系統核心(Xen kernel or kernel-xen). 半虛擬化的作業系統(guest)在執行時可以共用主系統(host)的資源(libraries and devices)。所以它相對的會比全虛擬化系統快速。
  • Full virtualization(全虛擬化)
    • 全虛擬化系統使用處理器的功能來提供整個硬體資源的抽象層(可以稱作虛擬機器),然後將所要安裝的作業系統安裝在它的上面,就好是裝在一台實體的機器一般。

2010年8月6日 星期五

Linux 提示符號 - Fancy Prompt & Color Theme

在 iTerm 及 linux command line mode 底下,預設的提示符號及色彩(無色彩),要辨別訊息,不是那麼容易,於是就來給它改造一番。底下分三個種類來說(我的 login shell 一律使用 bash):

一、Mac OS X iTerm 底下的提示符號 (Regular Prompt)
底下是我的 ~/.bash_profile 的一部份

if [ "$PS1" ]; then
    case $TERM in
    xterm*)
        if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
            PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
        else
            PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
        fi
        ;;
    screen)
        if [ -e /etc/sysconfig/bash-prompt-screen ]; then
            PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
        else
            PROMPT_COMMAND='echo -ne "\033_${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
        fi
        ;;
    *)
        [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
        ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    PS1="\[\033[0;32m\][\u@\h:\[\033[0;33m\\w\[\033[0;32m\]]$\[\033[0m\] "
fi

export LANG=zh_TW.UTF-8
export CLICOLOR=1

粗體的部份,
PS1="\[\033[0;32m\][\u@\h:\[\033[0;33m\\w\[\033[0;32m\]]$\[\033[0m\] "
是用來改造命令提示符號的,

export CLICOLOR=1

是用來啟動色彩的。

二、Linux 底下的提示符號 (Fancy Bash Prompt)
原文請參考這裡 http://www.debian-administration.org/articles/205
簡單的說,就是把那一串 shell script 存成一個檔,例:~/.fancy_bash_prompt ,然後,在你的 ~/bash_profile 的最後面,加上

. ~/.fancy_prompt

就可以了。

三、Mac OS X 下 iTerm 的 color theme (對投影來說,特別容易辨別)
原文請參考這裡 http://kpumuk.info/mac-os-x/customizing-iterm-creating-a-display-profile-with-pastel-colors/

先關閉你的 iTerm, 接著啟動 Terminal.app,然後

你可以使用以下方式,安裝最新的 pastel theme

$ bash  (curl http://gist.github.com/raw/473731/iterm_pastel_theme.sh)


Enjoy ~~

2010年7月15日 星期四

iPad Jailbreak (JB)

7月初,拿到滾燙燙的 iPad wifi 64G 之後,就想到直接上 JB,免得跟 iPhone 3G 一樣,一開始沒有JB,日後怕出問題,一直沒有上 JB.

在爬了文,及詢問過同事之後,大家都說現在 JB 跟吃飯一樣,幾個 click 就好了。於是就下定決心開始了......

系統/環境資訊:

- Mac OS X 10.6.3
- iTune 9.2
- iPad OS 3.2

步驟一,備份 SHSH:
- Open iTune Apps on Mac.
- Connect iPad to USB, then iTune will detect it.
- Download and install backup application: TinyUmbrella (google it)

- Open TinyUmbrella, then it will detect your iPad and your OS version.
- Click on "Advanced Options" in TinyUmbrella Apps.
  - you will see your "ECID" on screen, which is Exclusive Chip ID.
  - select "Location" to "Cydia"
  - click "Save My SHSH"
    -The file will be saved in your local machine ($HOME/.shsh/) and Cydia server.
- Done.

步驟二,JailBarek:
- Download and install "SPIRIT" software.
- Open SPIRIT.
- SPIRIT will detect that your iPad is connected.
- Just click "Jailback". within 1 sec and it's done. (三小,這樣就完成了喔!)
  - Don't click "Close" yet until iPad has been rebooted.
  - iPad is rebooting.
- JB is done, Quit SPIRIT.

步驟三,Initializing Cydia:
- on iPad, click "Cydia" to initialize. 
- Done

步驟四,安裝 AppSync , 讓 *.ipa (Apps 檔案格式)可以直接裝到 iPad 上:
- Open Cydia
- Click Manage, and click Source
- Add a source: http://cydia.hackulo.us
- After that, Click Hackulo source, then select AppSync OS 3.2 to install.
- Done.

~~~~~~ Happy Play Around Your iPad ~~~~~~

2010年6月2日 星期三

Add Additional YUM Repository to Redhat EL5

在標準的 Redhat EL5 底下,yum 的 repository 只提供官方的版本。日前,因為工作需要要裝以下的 library or package 給 PHP 使用,

pecl/json
pecl/imagick

可是在官方版本底下,找不到相關的套件;嘗試用 'pecl install imagick' 重新編譯時,又會發生找不到 libWand.so 相關的函式庫。在網路上 google 了一番,發現在 EPEL(Extra Package for Enterprise Linux) 有現在的 rpm 可用,所以就試著把它裝起來,以下是所有的步驟。

--------------------------------------------------------------------
Add the following two files into '''/etc/yum.repos.d'''

filename: /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 5 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch/debug
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch
failovermethod=priority
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 5 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/5/SRPMS
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch
failovermethod=priority
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1

filename: /etc/yum.repos.d/epel-testing.repo
[epel-testing]
name=Extra Packages for Enterprise Linux 5 - Testing - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/testing/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=testing-epel5&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

[epel-testing-debuginfo]
name=Extra Packages for Enterprise Linux 5 - Testing - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/testing/5/$basearch/debug
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=testing-debug-epel5&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1

[epel-testing-source]
name=Extra Packages for Enterprise Linux 5 - Testing - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/testing/5/SRPMS
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=testing-source-epel5&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1

Also you need to import the gpg key for the repository as follows: (check out latest location of file: https://fedoraproject.org/keys)
$ cd /etc/pki/rpm-gpg
$[/etc/pki/rpm-gpg] wget -o RPM-GPG-KEY-EPEL https://fedoraproject.org/static/217521F6.txt
$[/etc/pki/rpm-gpg] sudo rpm -import RPM-GPG-KEY-EPEL

2010年5月20日 星期四

在 Chrome on Mac 上移除擾人的 google translate bar

最近用 Google Chrome 的時候,被那個惱人的 translate bar 搞得很火,所以就辦法看能不能把它 disable 掉;找來找去,遍尋不著。後來,想到直接到檔案系統裡,找出它的設定檔來改。

設定檔位置:  ~/Library/Application Support/Google/Chrome/Default/Preferences

裡頭會有幾個跟 translate 相關的設定,如下:


   "translate_language_blacklist": [ "zh-TW" ],
   "translate_site_blacklist": [ "xfalcons.blogspot.com", "mail.google.com", "www.facebook.com", "www.plurk.com", "udn.com", "www.google.com.tw", "tw.yahoo.com" ],

我的設定方式是將所有 zh-TW, googe.com, yahoo.com ... 等,不想要 translate bar 的站,都加到裡面去,這樣,就不會被那個 bar 一直推來推去了。

2010年4月13日 星期二

[PHP] upload file 的同時,存取其他的 parameters

幾天前,被問到 html form 在 upload file 的同時,如何存取其他的參數?太久沒寫 code ,一時也無法確定,所以寫了個測試程式。結果是可以用 $_POST 拿到。

[upload_form.html]
------
....

form action="http://192.168.0.1:80/ws/uploadFile" enctype="multipart/form-data" method="post"
input name="t" type="hidden" value="1271143058" 
input name="expire" type="hidden" value="1271143063" 
input name="routerAccessKeyId" type="hidden" value="05f6adb19e46f06ef0515f24e2dc586e" 
input name="sig" type="hidden" value="e53a274015c4ab6670faa98775827c3b" 
input name="path" type="hidden" value="/usb1/muchiii/photo" 
input name="callback" type="hidden" value="_getdata_123456" 

input name="filename" type="file" 
...
...
------

[uploadFile.php]
------
var_dump($_POST);
print "\n";
var_dump($_FILES);
------

得到以下結果。
------
array(6) {
  ["t"]=>
  string(10) "1271143058"
  ["expire"]=>
  string(10) "1271143063"
  ["routerAccessKeyId"]=>
  string(32) "05f6adb19e46f06ef0515f24e2dc586e"
  ["sig"]=>
  string(32) "e53a274015c4ab6670faa98775827c3b"
  ["path"]=>
  string(19) "/usb1/muchiii/photo"
  ["callback"]=>
  string(15) "_getdata_123456"
}

array(1) {
  ["uploadedfile"]=>
  array(5) {
    ["name"]=>
    string(18) "OverallSystem1.png"
    ["type"]=>
    string(9) "image/png"
    ["tmp_name"]=>
    string(14) "/tmp/phpNbiLMY"
    ["error"]=>
    int(0)
    ["size"]=>
    int(86265)
  }
}
------

2010年2月2日 星期二

USB SATA 外接硬碟如何在 Mac OS & Windows XP 之間共享及讀寫

之前把這顆 USB SATA 硬碟,格式化成 Mac OS Extended Journaled,然後,用在 2 台 macbook pro 之間透過 rsync 做備份及同步我的 home directory,沒有什麼大的問題。

有天,想要把我另一台 Windows XP 上 download 下來的電影檔要 copy 到 MacbookPro,發現 Windows XP 竟然認不得這顆外接 USB 硬碟;原來,Windows XP 是認不得 "Mac OS Extended Journaled" 的檔案格式,只好來將它 format 成 FAT32 格式。

之後,將 USB 硬碟做了第二份備份之後,就把它放在 MacbookPro 裡,格式化成 FAT32。接下來,接到 Windows XP 的電腦上。看起來是可以用了,可是之後發現了另一個問題,就是 FAT32 格式,不支援單一檔案超過 4GB;只有 NTFS 可以支援,可是 Mac OS 又不認得 NTFS 格式(Leopard 之前,縱使認得,也只能讀,不能寫)。那到底我要用什麼格式呢?

在考量這顆外接 USB 硬碟的穩定性(“建達“出奇蛋,果然是蛋,很脆弱),就放棄它當做 MacbookPro 的備份硬碟,而拿它來做為 Windows XP 下的第三顆硬碟。

即然要 format 成 NTFS,當然就選擇在 Windows XP 下進行;在著手 format 它的過程中,又發現,它有一個奇怪的分割區,叫做“GPT保護的磁碟分割“,沒有辦法刪除它;google 了一下,發現原來它是 Vista or Windows 7 額外建出來的 partition,用來保護資料用的;不過在 Windows XP 下,它是沒有作用的,所以就想辦法來刪除它。以下是刪除它的方法

==================================================================
Windows XP → 開始 → 執行 → diskpart

接著輸入 list disk 查看所有磁碟機編號

選擇你要修改的磁碟, 假設是 disk 1, 就輸入 select disk 1 來選擇 磁碟#1

最後在輸入 clean

搞定
==================================================================

之後,再到 「控制台」-「系統管理工具」-「電腦管理」做 partition 及 format 成 NTFS 即可。

當當當,接下來,這顆 USB 外接硬碟雖然在 mac 端可以讀取,但是卻不能寫入。有二個方式:

1. MacFUSE + NTFS-3G
2. NTFS Mounter

二種方式,都各有利幣,就看你的需求而定囉!基本上,我會以「讀取」為主,偶而用用「寫入」,所以我選 NTFS Mounter.

2010年1月22日 星期五

Mac OS X Server v10.6: Starting up with the 32-bit or 64-bit kernel

Summary

Mac OS X Server v10.6 Snow Leopard includes a new 64-bit kernel that increases performance and scalability on supported hardware. On hardware that supports the 64-bit kernel, you can choose whether to start up (boot) your server using the new 64-bit kernel or the earlier 32-bit kernel.

Note: To determine whether or not your server can use the 64-bit kernel, and which kernel it uses by default, see this article.

Products Affected
Mac OS X Server 10.6

You can use either of these methods:

Method 1: Startup key combination (for current startup only)

  • If your server uses the 32-bit kernel by default, but supports the 64-bit kernel, you can start up using the 64-bit kernel by holding the 6 and 4 keys during startup.
  • If your server uses the 64-bit kernel by default, you can start up with the 32-bit kernel by holding the 3 and 2 keys during startup.

Your server will revert to the default kernel the next time you reboot it.

Method 2: On-disk setting (persistent)

To select the 64-bit kernel for the current startup disk, use the following command in Terminal:
sudo systemsetup -setkernelbootarchitecture x86_64

To select the 32-bit kernel for the current startup disk, use the following command in Terminal:
sudo systemsetup -setkernelbootarchitecture i386

Note: This setting is stored in the /Library/Preferences/SystemConfiguration/com.apple.Boot.plist file and will take effect every time you start up from this disk. If you start up from a different disk, the setting on that disk, or the hardware default, will take effect.

Additional Information

  • Keys held during startup (such as 3-2 or 6-4, method 1 above) will override the setting in com.apple.Boot.plist (method 2 above).

如何克服公司檔我 facebook on MacBook

Configure Routing Table For Facebook in MAC OSX by Kevin.L

It's very troublesome while you need to access both Facebook and internal resources.
You need to switch internet connection to acheive this manually.
You only need to execute the following command in TERMINAL.
After that you don't have to switch between connections anymore.
PS: You need to connect to wireless SSID: muchiii_lab_dir685(hinet) first.

sudo route  add -net 69.63 192.168.0.1 255.255.0.0

關機時,自動設定
1. 增加一個目錄 AddRoutes 到 /Library/StartupItems/
2. 在 AddRoutes/ 目錄下,新增一個檔案叫 StartupParameters.plist
        Description     = "Add static routing tables";
        Provides        = ("AddRoutes");
        Requires        = ("Network");
        OrderPreference = "None";

3. 在 AddRoutes/ 目錄下,新增一個檔案叫 AddRoutes (沒錯,它跟目錄名稱一樣)
#!/bin/sh
# Set up static routing tables
# Roark Holz, Thursday, April 6, 2006

. /etc/rc.common

StartService ()
{
        ConsoleMessage "Adding Static Routing Tables"
        /sbin/route add -net 69.63 192.168.0.1 255.255.0.0
        /sbin/route add -net 66.220 192.168.0.1 255.255.0.0
}

StopService ()
{
        return 0
}

RestartService ()
{
        return 0
}

RunService "$1"