Wednesday, June 29, 2011

How to install GIT repo in ZyXEL NSA-320

ZyXEL NSA-320 is 1.2GHz NAS box with maximum of 2 x 2T harddisk (SATA I/II only)
The current firmware is 4.01 and is OK for the fun_plug

This box provides a very cheap alternative for the git repo plus your other storage need such as video, music download and backup as well.

You can gain telnet access following the instruction here : http://zyxel.nas-central.org/wiki/FFP-stick

and if you want to install GIT repo in this box, follow these steps.

(1) Follow the instruction here to gain telnet access, enable ssh server in the box, move the ffproot to harddisk and reboot your NAS box
http://zyxel.nas-central.org/wiki/FFP-stick

If you failed the installation, I suggest you to download this directly http://www.inreto.de/dns323/fun-plug/0.5/fun_plug.tgz and put the fun_plug.tgz in your USB stick rather than let it download during setup.

(2) install all packages (as you need most of them to build the git binary) from here
assume your server ipaddress is 192.168.0.10 and use ssh to access the NAS box

ssh root@192.168.0.10
mkdir -p /ffp/pkg
cd /ffp/pkg
rsync -av inreto.de::dns323/fun-plug/0.5/packages .
cd packages
funpkg -i *.tgz


(3) remove dns323 utilities which are not useful for NSA-320
funpkg -r dns323-utils-0.7.176-2.tgz

(4) install PERL & python
cd /ffp/pkg
wget http://www.inreto.de/dns323/fun-plug/0.5/extra-packages/perl/perl-5.10-2.tgz
wget http://www.plord.co.uk/funplug/0.5/python-2.6.4-1.tgz
funpkg -i python-2.6.4-1.tgz perl-5.10-2.tgz


(5) install the build environment
mkdir -p /i-data/md0/ffpbuildenv
cd /i-data/md0/ffpbuildenv
svn co svn://inreto.de/svn/dns323/funplug/trunk .


(6) modify the file chroot.sh to this
chroot.sh Select all

#!/ffp/bin/sh
set -x
CWD=$(pwd)
ffp=$(readlink -f /ffp)
root=/ffp-chroot
if [ -d "$root" ]; then
echo "$root exists"
exit 1
fi

mkdir -p $root
cd $root

mkdir -p ffp dev etc proc sys mnt i-data/md0
mount -t proc proc proc
mount -t sysfs sysfs sys
mount --bind /dev dev
mount --bind /etc etc
mount --bind $ffp ffp
mount --bind /i-data/md0 i-data/md0

ln -s ffp/bin bin
ln -s ffp/lib lib
ln -s ffp/sbin sbin
ln -s ffp usr
ln -s i-data/md0/ffproot/home home

chroot . $SHELL

umount i-data/md0
umount ffp
umount etc
umount dev
umount sys
umount proc

rm bin lib sbin usr home
rmdir ffp dev etc proc sys i-data/md0 mnt
rmdir i-data

cd ..
rmdir $root


(7) chroot to the build environment and get the git source and install it in NAS box

cd /i-data/md0/ffpbuildenv
sh chroot.sh
cd i-data/md0/ffpbuildenv/source
wget http://kernel.org/pub/software/scm/git/git-1.7.6.tar.bz2
tar xjvf git-1.7.6.tar.bz2
cd git-1.7.6
./configure --prefix=/ffp
NO_NSEC=YesPlease make install


(8) after installation of git, exit the build environment

exit


(9) create git repo in the box (from your desktop)

ssh root@192.168.0.10 "mkdir -p /home/root/git/yourproject.git; cd /home/root/git/yourproject.git; git --bare init; touch git-daemon-export-ok"


(10) push your project to the git repo in the NAS box (from your desktop)

cd ~/yourprojectdir
git init
git add . # include everything below ./ in the first commit;
# if you want to remove use git rm -r --cache xxx
git commit
git remote add origin ssh://root@192.168.0.10/home/root/git/yourproject.git
git push origin master


(11) If you don't want to build it. Just download this package and install it using funpkg -i git-1.7.6.tgz However, you still need to have some package dependencies like PERL & python in order to run.

.
.
.