NOTE: (08/11/2015) 本文是多年前的老機器 DS107 的紀錄, 這台機器的 DSM 已經停止更新, 當時他是無法透過 DSM 安裝 GIT 套件, 所以只能手動(ipkg)安裝, 最近購入 DS214 發現新的 DSM 上已經有套件可以直接安裝, 如果你的 DSM 有支援線上安裝 GIT Server 請不要再看本文, 參見 Synology Git 套件說明 或新版的 如何在 Synology NAS 設置 GIT 伺服器 (新版) ^^
========================================
本來想放棄用 NAS(with Linux) 這樣做, 但 google 了一下 GIT server 架在 Windows 或 Linux 給外網的人使用, 要搭 HTTP 或 SSH 等等, 安裝看來沒有誰比較簡單, 內網不管權限最簡單, 就是一個內部目錄位置就好了, 不然就是得用 FREE 或收費的 GIT HOST 雲端的服務. 所以還是嘗試看看...
NOTE: 這是我的私人記錄, 不是教學!
環境:
1. Synology DS107+ DSM 3.1-1636 版
2. 有實體 IP 11.22.33.44 (此為亂寫)
How to setup a GITserver on a Synology NAS
-------------------------------------------
1. 開啟 SSH
a) 用瀏覽器打開 NAS 的網頁管理頁面 "11.22.33.44:5000"
b) 打開 "控制台" -> "終端機" 在 "啟動SSH功能" 打勾,按 "確定".
2. 在 Windows 下執行 SSH client 以 'root' 登入至 NAS
NOTE: 1. 要求輸入密碼時請直接鍵入網頁管理頁面(admin)用的密碼.
2. 可以使用 Cygwin 的 ssh, 或是 PuTTY
$ ssh 11.22.33.44 -l root -p 22
root@11.22.33.44's password: xxxx
BusyBox v1.16.1 (2011-10-23 04:33:17 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.
NOTE: 一般 SSH 預設 port 為 22 如果沒有改過, -p 22 可以不用加.
3. 進入 /volume1/@tmp
DiskStation> cd /volume1/@tmp
DiskStation> ls -al
drwxrwxrwx 4 root root 4096 Mar 25 15:25 .
drwxrwxrwx 12 root root 4096 Apr 2 11:10 ..
drwxrwxrwt 3 root root 4096 Mar 25 15:25 php
drwxrwxrwx 2 root root 4096 Apr 1 18:53 webfm
4. 抓取 bootstrap
NOTE: 1. bootstrap 是安裝 ipkg 的執行劇本, 各 CPU 不一樣, 請先看好機
型的 CPU.
What_kind_of_CPU_does_my_NAS_have
看好要下載正確的 xsh 文件 URL 位置:
Modifying_the_Synology_Server,_bootstrap,_ipkg_etc
2. 為避免網址輸錯, 建議直接複製 xsh 文件的網址, 下面 wget 後面直
接 "貼上".
DiskStation> wget http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/syno-x07-bootstrap_1.2-7_arm.xsh
--16:47:02-- http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/syno-x07-bootstrap_1.2-7_arm.xsh
=> `syno-x07-bootstrap_1.2-7_arm.xsh'
Resolving ipkg.nslu2-linux.org... 140.211.169.161
Connecting to ipkg.nslu2-linux.org|140.211.169.161|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 250,349 (244K) [text/plain]
100%[====================================>] 250,349 190.89K/s
16:47:04 (190.41 KB/s) - `syno-x07-bootstrap_1.2-7_arm.xsh' saved [250349/250349]
DiskStation> ls -al
drwxrwxrwx 4 root root 4096 Apr 2 16:47 .
drwxrwxrwx 12 root root 4096 Apr 2 11:10 ..
drwxrwxrwt 3 root root 4096 Mar 25 15:25 php
-rw-rw-rw- 1 root root 250349 Feb 20 2012 syno-x07-bootstrap_1.2-7_arm.xsh
drwxrwxrwx 2 root root 4096 Apr 1 18:53 webfm
5. 改變 script 為可執行屬性
DiskStation> chmod +x syno-x07-bootstrap_1.2-7_arm.xsh
6. 執行 script
DiskStation> sh syno-x07-bootstrap_1.2-7_arm.xsh
Optware Bootstrap for syno-x07.
Extracting archive... please wait
bootstrap/
bootstrap/bootstrap.sh
bootstrap/ipkg-opt.ipk
bootstrap/ipkg.sh
bootstrap/optware-bootstrap.ipk
bootstrap/wget.ipk
1226+1 records in
1226+1 records out
Creating temporary ipkg repository...
Installing optware-bootstrap package...
Unpacking optware-bootstrap.ipk...Done.
Configuring optware-bootstrap.ipk...Setting up ipkg arch-file
Modifying /etc/rc.local
Done.
Installing ipkg...
Unpacking ipkg-opt.ipk...Done.
Configuring ipkg-opt.ipk...WARNING: can't open config file: /usr/syno/ssl/openssl.cnf
Done.
Removing temporary ipkg repository...
Installing wget...
Installing wget (1.12-2) to root...
Configuring wget
Successfully terminated.
Creating /opt/etc/ipkg/cross-feed.conf...
Setup complete.
BusyBox v1.16.1 (2011-11-26 14:58:46 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.
7. 刪除 script
DiskStation> rm syno-x07-bootstrap_1.2-7_arm.xsh
8. 如果是 DSM 4.0 還需要修改 /root/.profile
(....P.S. 我是 DSM 3.1 所以此處我是跳過)
請參考下面連結, 第八步驟 NEW: If you have DSM 4.0 there is an additional step...
Modifying_the_Synology_Server,_bootstrap,_ipkg_etc
9. 執行 ipkg update
DiskStation> ipkg update
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/Pa
ckages.gz
Inflating http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/Pack
ages.gz
Updated list of available packages in /opt/lib/ipkg/lists/cross
Successfully terminated.
10. 執行 ipkg upgrade
DiskStation> ipkg upgrade
Nothing to be done
Successfully terminated.
11. 安裝 git
DiskStation> ipkg install git
Installing git (1.8.2-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/git_1.8.2-2_arm.ipk
package git suggests installing git-manpages
Installing zlib (1.2.5-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/zlib_1.2.5-1_arm.ipk
Installing openssl (0.9.7m-6) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/openssl_0.9.7m-6_arm.ipk
Installing libcurl (7.24.0-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/libcurl_7.24.0-1_arm.ipk
Installing diffutils (3.1-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/diffutils_3.1-1_arm.ipk
Installing rcs (5.7-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/rcs_5.7-2_arm.ipk
Installing expat (2.0.1-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/expat_2.0.1-1_arm.ipk
Configuring diffutils
update-alternatives: Linking //opt/bin/cmp to /opt/bin/diffutils-cmp
update-alternatives: Linking //opt/bin/diff to /opt/bin/diffutils-diff
update-alternatives: Linking //opt/bin/diff3 to /opt/bin/diffutils-diff3
update-alternatives: Linking //opt/bin/sdiff to /opt/bin/diffutils-sdiff
Configuring expat
Configuring git
Configuring libcurl
Configuring openssl
Configuring rcs
Configuring zlib
Successfully terminated.
13. 設置 git 的各命令可以不帶路徑直接叫用
P.S. 這是因為 ipkg 安裝 git 是放在 /opt/bin 下, 非系統的 $PATH 下能找到, 有兩個方法:
a) 最簡單的方式是...建立檔案連結 ("有點" 像 Windows 的捷徑).
DiskStation> for f in `ls /opt/bin/git*`
> do
> ln -s $f /usr/bin
> done
b) 在建立 git user 後修改的 login 環境變數.
(....我是用 a 法, 所以此處我沒試)
請參考下面連結, 第6步驟 ..."git-upload-pack" on the NAS was not found in the $PATH....
14. 建立 git 帳號及共享目錄
繼續...如何在 Synology NAS 設置 GIT 伺服器 (2/2)
參考:
http://ti57.blogspot.tw/2013/01/how-to-setup-git-server-on-synology-nas.html
http://www.wonko.de/2010/04/set-up-git-on-synology-nas.html
沒有留言:
張貼留言