It's going to be my primary Data Silo so naturally I need to store my (backup-/published-) git repos there.
The Synology thing I bought comes with Linux/Busybox. Hacking around is surprisingly easy, they actually encourage you to do it.
Of course I could have gone the easy way of nfs-mounting my shares and then have used local paths to update the repos. But I wanted to be able to do this from the road using ssh. So I needed git to be Installed.
Here is what I needed to do to install git on the Box:
- Open ssh. Easy its in the GUI.
- Create users and shares
- Set up your User accounts to:
- Have a proper Home Directory
- Be able to log in using Public/Private keys
- Configure Additional Software Repositories
- Install git
- Configure sshd so that git+ssh works
1. Open ssh
Open the Web interface of the Box.
Select the "Management" View.
Go to "Network Services" -> "Terminal"
Select "Enable SSH service" and click "OK"
2. Create users and shares
Go to "Privileges" -> "User" and create a User
We need at leas one share to be able to transfer a File to the Box.
3.Set up your User accounts
Use ssh to log in as "root" on the box. Use the "Admin" password that you provided when
Initially setting up the NAS.
You will see the Busybox promt:
BusyBox v1.1.0 (2010.03.12-16:58+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands. syn>
create home directories for your users:
mkdir -p /volume1/home/user1
Then edit /etc/passwd to enable the user for ssh use. We change he home dir set the login shell:
... user1:x:1026:100::/volume1/home/user1:/bin/sh ...
By the way. /bin/sh is NOT Bash here. Its Busybox (ash).
Now you should be able to access the NAS through ssh with that user.
For convenience we want to be able to use Public/Private keys for login:
Edit /etc/ssh/sshd_config and change the Lines regarding Public Key Authentication:
... PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys ...
Oddly this sometimes only works half way. If your sshd does not come back, simply switch it back on in the Web interface.
Now copy your public key to a share and move it to the authorized_keys file:
mkdir -p /volume1/home/user1/.ssh mv /volume1/someshare/id_dsa.pub /volume1/home/user1/.ssh/authorized_keys
Now you should be able to log in without a password.
4. Configure Additional Software Repositories
Pretty straight forward as described in the Synology wiki
Copy the boostrap file to a Share ( syno-mvkw-bootstrap_1.2-7_arm.xsh), then run it as root on the box:
5. Install git
Look for the git package:
ipkg list|grep git dcraw - 1.376-2 - Decoding raw digital photos. digitemp - 3.6.0-1 - Reads 1-Wire Temperature sensor (http://www.digitemp.com) git - 18.104.22.168-1 - GIT is a directory tree content manager that can be used for distributed revision control. git-lite - 22.214.171.124-1 - GIT is a directory tree content manager that can be used for distributed revision control. git-manpages - 126.96.36.199-1 - manpages of git git-svn - 188.8.131.52-1 - git as svn client gitosis - git20090917-1 - Git repository hosting application. gphoto2 - 2.4.1-1 - Command line digital camera software applications libdlna - 0.2.3-2 - Reference DLNA (Digital Living Network Alliance) open-source implementation for Linux. libgphoto2 - 2.4.1-1 - digital camera software libraries sane-backends - 1.0.20+git20091022-1 - SANE is a universal scanner interface squeezecenter - 7.3.3-1 - Streaming Audio Server for Logitech Squeezebox stgit - 0.14.3-2 - StGit is a Python application providing similar functionality to Quilt (i.e. pushing/popping patches to/from a stack) on top of tig - 0.15-1 - Tig is a git repository browser that additionally can act as a pager for output from various git commands.
ipkg install git
Now we can create a repo for publishing. Log in as your user:
mkdir -p /volume1/git/test cd /volume1/git/test git init --bare Initialized empty Git repository in /volume1/git/test/
6.Configure sshd so that git+ssh works
Now git works in regular login shells. When using git to clone the new repo this fails:
git clone ssh://192.168.178.29/volume1/git/test Initialized empty Git repository in /data/t/.git/ sh: git-upload-pack: not found fatal: The remote end hung up unexpectedly
This means that the "git-upload-pack" on the NAS was not found in the $PATH.
The ipkg Packages are installed to /opt/(s)bin which is not in sshds standard path.
Since sshd for BusyBox was configured not to parse /etc/profile or ~/.profile we have to fall back to providing a ~/.ssh/environment file with the correct path:
The Path can be copied from /root/.profile
To switch on user environments in sshd, configure /etc/ssh/sshd_config :
... PermitUserEnvironment yes ...
Then restart sshd.