一直想搞一台git server做個版本控制,趁著今天颱風天,就把git server架在家裡的Synology NAS上吧!

1. 取得 Bootstrap

查表 http://forum.synology.com/wiki/index.php/What_kind_of_CPU_does_my_NAS_have 根據你的Synology NAS型號查詢

CPU型號以下載並安裝Bootstrap.

以我的DS410為例,取得規格資訊為 Freescale PowerQUICC III MPC8533E PPC

接著,就是前往 http://forum.synology.com/wiki/index.php/Overview_on_modifying_the_Synology_Server,_bootstrap,_ipkg_etc#Bootstrap

下載所需要的Bootstrap並且安裝。得到以下資訊:

For 8533 PPC models - Please use the bootstrap for the 8543 PPC CPU (see below). That bootstrap is compatible with both 8533 and 8543 CPU's

For 8543 PPC models http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/syno-e500-bootstrap_1.2-7_powerpc.xsh which uses http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/ as its feed.

8533相容於8543,因此下載8543即可。

2. 下載Bootstrap

先於Synology NAS的WEB介面之“控制台“->"終端機”勾選"啟動SSH功能“

在使用pietty之類的SSH連線軟體通過SSH連線至Synology NAS的指令模式。

再使用指令wget及Bootstrap的下載路徑進行下載。

例如:wget http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/syno-e500-bootstrap_1.2-7_powerpc.xsh

3. 安裝Bootstrap

執行指令 chmod +x syno-e500-bootstrap_1.2-7_powerpc.xsh

然後 ./syno-e500-bootstrap_1.2-7_powerpc.xsh

便完成安裝。

4. 使用 ipkg 安裝套件

輸入指令 ipkg update

FrankData> ipkg update
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/Packages.gz
Inflating http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/Packages.gz
Updated list of available packages in /opt/lib/ipkg/lists/cross
Successfully terminated.

輸入指令 ipkg upgrade

FrankData> ipkg upgrade
Upgrading file on root from 5.09-1 to 5.12-1...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/file_5.12-1_powerpc.ipk
Upgrading git on root from 1.8.0.1-1 to 1.8.2.3-2...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/git_1.8.2.3-2_powerpc.ipk
package git suggests installing git-manpages
Upgrading ncurses on root from 5.7-1 to 5.7-3...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/ncurses_5.7-3_powerpc.ipk
Upgrading ncursesw on root from 5.7-1 to 5.7-2...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/ncursesw_5.7-2_powerpc.ipk
Upgrading neon on root from 0.29.3-1 to 0.29.6-1...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/neon_0.29.6-1_powerpc.ipk
Configuring file
Configuring git
Configuring ncurses
update-alternatives: Linking //opt/bin/clear to /opt/bin/ncurses-clear
Configuring ncursesw
Configuring neon
Successfully terminated.
FrankData>

再來輸入指令 ipkg install git 即可完成 git server 環境的安裝

git 套件安裝完成後,會包含 git 指令,這個指令可以用來下載遠端git server的source code或者建立屬於本機自己的repository

透過所建立的 git repository就能開始規劃專屬的版本控制環境。

5. 建立git repository

透過 SSH 進入 Synology NAS 命令模式,輸入指令

mkdir /volume1/gitroot

cd /volume1/gitroot

mkdir test.git

cd test.git

git --bare init

6. 於其他用戶端電腦,如裝有Ubuntu Linux 的命令模式,輸入指令

git clone access_git_server_account@your_git_server:your_git repository_path.git

如果出現 git-upload-pack not found 的錯誤訊息,代表你的Synology NAS的路徑設定有誤,導致無法找到 git-upload-pack的指令

此時,請參考以下說明進行處理即可順利解決。

Make sure git-upload-pack is on the path from a non-login shell. (On my machine it's in /usr/bin).

To see what your path looks like on the remote machine from a non-login shell, try this:

ssh you@remotemachine echo \$PATH

(That works in Bash, Zsh, and tcsh, and probably other shells too.)

If the path it gives back doesn't include the directory that has git-upload-pack, you need to fix it by setting it in .bashrc (for Bash), .zshenv (for Zsh), .cshrc (for tcsh) or equivalent for your shell.

You will need to make this change on the remote machine.

If you're not sure which path you need to add to your remote PATH, you can find it with this command (you need to run this on the remote machine):

which git-upload-pack

On my machine that prints /usr/bin/git-upload-pack. So in this case, /usr/bin is the path you need to make sure is in your remote non-login shell PATH.

參考資料取自 http://stackoverflow.com/questions/225291/git-upload-pack-command-not-found-how-to-fix-this-correctly

7. git repository 執行 git commit

git add 要加入版控的檔案或資料夾

git commit 為此次的修改或增加填寫註解

git push origin master 提交至 git repository

以上為個人在 Synology NAS DS-410 建置 git server 的筆記,敬請參考,歡迎交流經驗,謝謝。

更多關於 git command 請參考 http://blog.longwin.com.tw/2009/05/git-learn-initial-command-2009/

 


文章標籤
創作者介紹

經驗交流分享與備忘

Frank 發表在 痞客邦 PIXNET 留言(0) 人氣()