DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

#1 2011-05-30 13:35:47

bellofresco
Member
Registered: 2011-05-30
Posts: 29

understanding ffp and compiling packages in a zyxel nsa-221

Hi,

I'm the owner of a Zyxel nsa-221. I write here as I suppose (at least I hope) this nas is similar to the 220 model.

I'm trying to package some application as the nas can't do what I bought it for.
In particular I'm interested in backup trogh ftp (for this I wish to use duplicity), print serving (221 natively doesn't support my printer - a canon mp830, so I wish to install drivers I found on openprinting.org, but they require LSB...) and scanner serving (sane?).

Ok , so for every goal I need the package and all dependencies package. I found some already packaged, but other no.
I found a tutorial written by Uli and tried to follow it, but I discored once I install fonz package on my nas I have not the same directory as those I should find following the Uli tutorial (or at least I believe so as I'm a linux beginner and maybe I do some errors...)

Anyway if I do an ls command on the root directory of nas I have this:

root@nas:/# ls
after_booting.sh  dev     etc  home    lib   sbin  usr
bin               e-data  ffp  i-data  proc  tmp   var


I have no /mnt directory but before I find an e-data (usb) and i-data (the lonely sata drive connected to the nas).

Furthermore if I explore etc (taht klinks me to /ffp/etc/ i find fstab
fstab contains this:

root@nas:/ffp/etc# cat fstab
/dev/mtdblock1          /                       squashfs        defaults       0 0
/proc                   /proc                   proc            defaults       0 0
/proc/bus/usb           /proc/bus/usb           usbfs           defaults       0 0
/sys                    /sys                    sysfs           defaults       0 0
/dev/md0                /ffp/mnt/md0            reiserfs        rw,user        0 0


I don't understan very well  but I think it tells me taht I should have a directory (or file) named md0 in the directory mnt in the directory ffp that is the mounting point of the device md0.
BUT in the directory ffp there is NO a directory mnt (or maybe it is hidden? but if I try cd to mnt I receive the message "can't cd to mnt")

root@nas:/ffp# ls
bin  etc  include  lib  libexec  man  pkg  sbin  share  start  tmp  var

So to compile new package I tried to install the environment on hd creating the folder ffbuildenv and using webversion in a folder of i-data directory that is my hard drive.
Then I tried to do a symbolic link creating a /mnt/HD_a2/ directory that links to the directory ffbuildenv on hard disk and running the sh chroot.sh script, but at that point when I cd
/mnt/HD_a2/  I can't cd in ffbuildenv/source.....

I tried also to mount /dev/sda (that should be my hard disk) on /mnt/HD_a2 but it tells me the device is busy...

So my question is: how to mangae/organize my folders and device to setup the compiling environment correctly? Or how should I edit (and in thi s case with which tool) the chroot.sh script (I think it could be possible also in this way)?

Thank you

Offline

 

#2 2011-05-30 17:12:54

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

I have checket the ffpboot.log and here is it:


root@nas:/e-data/4DDE-8544# cat ffpboot.log
ffpboot.log       ffpboot.log.1.gz
root@nas:/e-data/4DDE-8544# cat ffpboot.log
Some logfile administration...
cat /mnt/parnerkey/ffpboot.log | gzip -c >/mnt/parnerkey/ffpboot.log.1.gz
Script usb_key_func.sh version 20101109 running from /mnt/parnerkey
ffpstick started at Sat May 28 22:57:54 GMT 2011
Try to determine NAS type...
Type NSA221, fw V4.10(AFM.0)
Find the current usb device...
Current usb device is /dev/sdb1
No after_booting.sh in the root of the ffpstick found
This is not the first run, or FFP is supposed to run from a different place
Copy myself to /tmp...
And execute...
/tmp/usb_key_func.sh background_polling /dev/sdb1 NSA221 "V4.10(AFM.0)" &
Script usb_key_func.sh version 20101109 running from /tmp
Wait for the stick to be mounted again by the firmware...
Probe all mount points 000 seconds...
probe /proc/bus/usb...
probe /dev/pts...
probe /zyxel/mnt/info...
probe /zyxel/mnt/NAND...
probe /zyxel/mnt/sysdisk...
probe /usr/local/etc...
probe /usr/local/var...
probe /usr/local/dmsf...
probe /etc/zyxel...
probe /i-data/129b5666...                                       
probe /e-data/4DDE-8544...
found ffpstick on /e-data/4DDE-8544, moving logfile
No /anymountpoint/ffproot/after_booting.sh found
Probe all mount points 010 seconds...
probe /proc/bus/usb...
probe /dev/pts...
probe /zyxel/mnt/info...
probe /zyxel/mnt/NAND...
probe /zyxel/mnt/sysdisk...
probe /usr/local/etc...
probe /usr/local/var...
probe /usr/local/dmsf...
probe /etc/zyxel...
probe /i-data/129b5666...
probe /e-data/4DDE-8544...
probe /usr/local/zy-pkgs...
probe /etc/zyxel/zy-pkgs...
probe /usr/local/apache/htdocs/zyxel/pkg...
No /anymountpoint/ffproot/after_booting.sh found
Probe all mount points 020 seconds...
probe /proc/bus/usb...
probe /dev/pts...
probe /zyxel/mnt/info...
probe /zyxel/mnt/NAND...
probe /zyxel/mnt/sysdisk...
probe /usr/local/etc...
probe /usr/local/var...
probe /usr/local/dmsf...
probe /etc/zyxel...
probe /i-data/129b5666...
probe /e-data/4DDE-8544...
probe /usr/local/zy-pkgs...
probe /etc/zyxel/zy-pkgs...
probe /usr/local/apache/htdocs/zyxel/pkg...
probe /usr/local/apache/web_framework/data/cache...
probe /usr/local/apache/web_framework/data/config...
No /anymountpoint/ffproot/after_booting.sh found
Probe all mount points 030 seconds...
probe /proc/bus/usb...
probe /dev/pts...
probe /zyxel/mnt/info...
probe /zyxel/mnt/NAND...
probe /zyxel/mnt/sysdisk...
probe /usr/local/etc...
probe /usr/local/var...
probe /usr/local/dmsf...
probe /etc/zyxel...
probe /i-data/129b5666...
probe /e-data/4DDE-8544...
probe /usr/local/zy-pkgs...
probe /etc/zyxel/zy-pkgs...
probe /usr/local/apache/htdocs/zyxel/pkg...
probe /usr/local/apache/web_framework/data/cache...
probe /usr/local/apache/web_framework/data/config...
No /anymountpoint/ffproot/after_booting.sh found
30 seconds should be enough for anybody wink
Will try to mount ffproot myself
Probe all mount points 040 seconds...
probe /proc/bus/usb...
probe /dev/pts...
probe /zyxel/mnt/info...
probe /zyxel/mnt/NAND...
probe /zyxel/mnt/sysdisk...
probe /usr/local/etc...
probe /usr/local/var...
probe /usr/local/dmsf...
probe /etc/zyxel...
probe /i-data/129b5666...
probe /e-data/4DDE-8544...
probe /usr/local/zy-pkgs...
probe /etc/zyxel/zy-pkgs...
probe /usr/local/apache/htdocs/zyxel/pkg...
probe /usr/local/apache/web_framework/data/cache...
probe /usr/local/apache/web_framework/data/config...
probe /e-data/a18e9ea7-9d5b-4f28-9f10-7bbcbf47b2ce...
found ffproot on /e-data/a18e9ea7-9d5b-4f28-9f10-7bbcbf47b2ce/ffproot
Starting /e-data/a18e9ea7-9d5b-4f28-9f10-7bbcbf47b2ce/ffproot/after_booting.sh version 20110323 at Sun May 29 01:01:01 CEST 2011...
mount: mount point sys does not exist                                                                  <---
Will chroot ffp on /e-data/a18e9ea7-9d5b-4f28-9f10-7bbcbf47b2ce/ffproot
* /ffp/start/syslogd.sh inactive
* /ffp/start/SERVERS.sh inactive
* /ffp/start/portmap.sh inactive
* /ffp/start/unfsd.sh inactive
* /ffp/start/nfsd.sh inactive
* /ffp/start/ntpd.sh inactive
* /ffp/start/smartd.sh inactive
* /ffp/start/LOGIN.sh inactive
* /ffp/start/telnetd.sh inactive
* /ffp/start/svnserve.sh inactive
* /ffp/start/sshd.sh ...
Starting /ffp/sbin/sshd
* /ffp/start/samba.sh inactive
* /ffp/start/rsyncd.sh inactive
* /ffp/start/mysqld.sh inactive
* /ffp/start/mediatomb.sh inactive
* /ffp/start/kickwebs.sh inactive
* /ffp/start/lighttpd.sh inactive
* /ffp/start/inetd.sh inactive
* /ffp/start/dnsmasq.sh inactive
* /ffp/start/btpd.sh inactive

I don't understand exactly what it is saying, but it seems to search for the after-booting script and not find it. Wher I have put the "<---" it doesn't find the mount point "sys" (mount: mount point sys does not exist). i don't know if this is the problem that cause not to have the /mnt directory or id it is a problem of this specific nas....

any help, idea or suggestion is welcome!

Offline

 

#3 2011-05-30 17:27:52

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

...a little progress...

reading the log file I discovered that hard disk is md0....mounting /dev/md0 on /mnt/HD_a2 now I have that directory and it is my hard drive....
i.e.  ls /mnt/HD_a2  shows me the content of hard disk......

I will try to go on with the tutorial of Uli starting here. I hope everything now will proceed without furtehr complications...

Offline

 

#4 2011-05-30 20:39:19

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 678

Re: understanding ffp and compiling packages in a zyxel nsa-221

I'm the owner of a Zyxel nsa-221. I write here as I suppose (at least I hope) this nas is similar to the 220 model.

Actually it's a complete different beast, but the software in compatible, as far as it concerns FFP.

You have found the right way, although I think it's a better idea to create a symlink /mnt/HD_a2 to /i-data/md0 instead of mounting /dev/md0 on it:

Code:

ln -s /i-data/md0 /mnt/HD_a2

(You'll have to umount and delete the directory HD_a2 first, a symlink cannot have the same name as an already existing file/directory.)
The reason why I think this is better, is because it will work directly at boot, and it won't confuse the firmware. (I'll add that symlink myself when I update the ffpstick package. You're not the first one stumbling upon this difference between ffp on the 323 and ffp on a Zyxel.)

And about that fstab, I think it's a bug. fstab is not handled by ffp, and I don't think the 221 uses reiserfs, so I think it's a residue of one of my early ffpsticks. I'll have a look at it. Further this is not the 'real' fstab, the real fstab (if it exists) is found in /etc/original.

You don't need to worry about the 'sys' error. The package tries to bindmount /sys on ffproot/sys, but /sys doesn't seem to exist. I can't remember the details, but I suppose this directory exists on some other Zyxel NAS. Anyway, it would be better to check for the existence, before trying to bindmount.

Last edited by Mijzelf (2011-05-30 20:41:26)

Offline

 

#5 2011-05-30 21:18:36

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

thank you very much...I will change as you suggested me creating a symlink.

In the meantime, I succeded in compiling the first package (at least I read a very beautiful "OK" at the end of process, but not installed yet).

It is NcFTP...I was becoming crazy with this as in the source directory I cerated its directory and called it NcFTP, but the Make.sh script then creates a directory called ncftp, so there is no corrispondence and the script die.

I tell this here to avoid others like me to create directory with upper case letters! This make die the script.....remeber..



Furthermore I'm trying to compiling also duplicity 6.0.13 but the script dies in this way:

FATAL: /ffp not found in package directory /mnt/HD_a2/ffbuildenv/work/duplicity-0.6.13/pkg

I read on the tutorial that another guy (Dirk) had the same problem and Uli suggested to set the PREFIX /ffp, unlikely not specified where...if in the configure.sh script to add to the application directory, or in the configure_args file. I tried both, but with the configure.sh file the script ends withiout doing anything (no errors but no package), with the second way the script dies as before with the FATAL....

I have also noticed that, while in the ffpbuildenv/work/ncftp..../ncftp... directory there is a configure script, the same doesn't exist in the relative directory of duplicity.....could be this the problem?
But for ncftp I didn't create it, I suppose it becomes with its source.....

another little help is really appreciated! tahnks

Offline

 

#6 2011-05-30 21:59:26

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 678

Re: understanding ffp and compiling packages in a zyxel nsa-221

The prefix is added like this:

Code:

./configure --prefix=/ffp

When building a package for ffp using configure, you should always specify this prefix. It tells the package it will live in the /ffp tree, and to use the libs in /ffp/lib instead of /lib.

Offline

 

#7 2011-05-30 22:13:47

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

where have I to put this code? in the configure_args file? i put it in the configure_args file inthe duplicity directory but without success...

Offline

 

#8 2011-05-30 22:24:31

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

for example, these is the configure_args of the source of mysql that I downloaded from fonz directories through the svn command:

root@nas:/mnt/HD_a2/ffbuildenv/source/mysql# cat configure_args
--with-unix-socket-path=$CPREFIX/var/run/mysql/mysql.sock
--localstatedir=/srv/mysql
--enable-thread-safe-client
--without-bench
--with-extra-charsets=complex
--with-vio
--with-openssl
--program-prefix="" --program-suffix=""
--with-mysqld-user=mysql
--with-low-memory


here the prefix is not set anywhere...??? a little confused...

Offline

 

#9 2011-05-30 22:52:59

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 678

Re: understanding ffp and compiling packages in a zyxel nsa-221

where have I to put this code?

Most packages contain a script 'configure'. To build these packages you'll have to run configure, from the package directory, so that is ./configure. This script checks for the environment (compiler, available libraries, ...) and generates a Makefile to actually build the package. So on a Linux box in most cases you can install a package from source by applying:

Code:

wget url/to/package.tar.gz
tar xzf package.tar.gz
cd package
./configure
make
su
make install

On an FFP box it's the same, except that you add '--prefix=/ffp' to ./configure. In most cases you can add more switches to ./configure, to specify how you want to build the package. For instance, apparently fonz doesn't build the option 'bench' in it's mysql package.
And about the missing --prefix, I don't know how fonz builds his packages, but I suppose there is a script somewhere that calls configure with the contents of configure_args, and also appends  --prefix=/ffp. The last option is applied to all packages, so he doesn't have to specify in all package specific stuff.

And about duplicity, I had a look at it, and it seems it's a bunch of python scripts. Alas I don't know anything about python, but I don't think the setup.py script will run when you don't at least change the header

Code:

#!/usr/bin/env python

to the real path of python. Maybe

Code:

#!/ffp/bin/python

Offline

 

#10 2011-05-31 00:09:45

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

Thank you very much Mijzelf, in one day I have learnt a lot about linux...



here....http://wiki.kartbuilding.net/index.php/Duplicity_-_secure_incremental_backup

I have found this...

"Duplicity does not run as a service, and has no default global configuration file. It is more a program/application rather than a service."

tomorrow I will try to create a configure file with the prefix and to put it into the package...let's see what happens...

About the code in the header of setup.py

#!/usr/bin/env python

it seems to be a comment, or am I wrong? I see the next lines are without the "#", while all the comments are with the"#"...
anyway I will test it tomorrow. Thank you again!

Offline

 

#11 2011-05-31 11:30:13

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 678

Re: understanding ffp and compiling packages in a zyxel nsa-221

Yes, it looks like a comment, and it is, in some way. Linux can execute binaries as well as scripts. When executing a script, the first line should contain a #!, followed by the full path to the script interpreter. So it tells the kernel which binary to start to execute the script (There are *many* script languages in Linux), but the script interpreter itself can handle it as a comment.

Offline

 

#12 2011-05-31 12:17:26

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

Ok, now I understand....unlikely I'm still fighting against this package compilation....

I tried to put a configure file inside the package but without luck...

now I wish to turn on the tutorial and set the configure.sh script.
As I have seen that in the configure file of ncftp (that was compiled succesfully) that the prefix is set to NONE, I have supposed
also in duplicity it has to be set the same, so my configure script is:


./config
--prefix=$CPREFIX


(I saw that Uli put "\" at the end of each line before teh last one: I have looked some other scripts on Google and they don't have them, so I didn't put)


Anyway, anyway I type the script or any parameters I put (i.e. both with --prefix="" (as Uli), both --prefix=/ffp) here is it what happens:

sh-3.2# ./Make.sh duplicity
* duplicity-0.6.13-1
  config.site found
  unpack duplicity-0.6.13.tar.gz ...
  configure.sh ...
sh-3.2#


as you can see the flow of operations seems to stop, exit and it goes back to the shell....


so I cat the Make.sh script trying to understand what happens when the configure.sh script is invoked
here is the part I think it calls the configure.sh script or check for configure_args...

# C configure
configure_args=
[ -r $X/configure_args ] && \
    eval configure_args=\"$(cat $X/configure_args | sed 's@#.*@@')\"
if [ -r $X/configure.sh ]; then
        info "  configure.sh ..."
        cd $B
        . $X/configure.sh
elif [ -x $S/configure ]; then
        info "  configure ..."
        cd $B
        eval $S/configure $configure_args
fi

$X is the directory of package in source directory, all the others I can't understand....

Furthermore I found a guy that in his blog has put a compiled package of duplicity (but an old version that seems to have some problems with ftp backup).
I have opened it and take a look. As you (Mijzelf) said, in this .py files the path for python has been changed.
Now I was guessing: could it be a good idea to build manually the package following the same sections I find in this already compiled package?

I tried twice to contact Drak0 to ask him how he did it, but everytime its blog answer that I am behind a proxy (not true) and that my messages are automatically blocked....unlikely there is no email of him....

Offline

 

#13 2011-05-31 12:57:01

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

reading the readme file of duplicity

INSTALLATION:

Thank you for trying duplicity.  To install, run:

        python setup.py install

The build process can be also be run separately:

        python setup.py build

The default prefix is /usr, so files are put in /usr/bin,
/usr/share/man/, etc.  An alternate prefix can be specified using the
--prefix=<prefix> option.  For example:

        python setup.py install --prefix=/usr/local
        export PYTHONPATH='/usr/local/lib/python2.x/site-packages/'
        /usr/local/bin/duplicity -V

I think that, maybe, differently of other applications, as it is all made by python scripts, it could be installed directly without packaging.
I.e., I want to try to give from shell the commands written above before using funpkg -i, once I have installed all dependencies and changed the payh for python libs...

Offline

 

#14 2011-05-31 13:02:45

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 678

Re: understanding ffp and compiling packages in a zyxel nsa-221

The \ is an escape character. It tells the shell that it shouldn't interpret the following character, but just is 'as is'. (And in most cases just pass it to another app). In this case the following character is the newline character, so the '\' means that the line just continues.

It's not clear to me where your Make.sh comes from. I downloaded duplicity 0.6.13, which doesn't contain any .sh scripts. But the README says:

Code:

INSTALLATION:

Thank you for trying duplicity.  To install, run:

        python setup.py install

The build process can be also be run separately:

        python setup.py build

The default prefix is /usr, so files are put in /usr/bin,
/usr/share/man/, etc.  An alternate prefix can be specified using the
--prefix=<prefix> option.  For example:

        python setup.py install --prefix=/usr/local
        export PYTHONPATH='/usr/local/lib/python2.x/site-packages/'
        /usr/local/bin/duplicity -V

You'll have to find out what PYTHONPATH should be, and supply the right prefix.

The next part is somewhat more complicated:

Code:

REQUIREMENTS:

 * Python v2.3 or later
 * librsync v0.9.6 or later
 * GnuPG v1.x for encryption
 * for normal ftp -- NcFTP version 3.1.9 or later, but not 3.2.0
 * for ftp over SSL -- lftp version 3.7.15 or later
 * Boto 0.9d or later

If you install from the source package, you will also need:

 * Python development files, normally found in module 'python-dev'.
 * librsync development files, normally found in module 'librsync-dev'.

Offline

 

#15 2011-05-31 13:17:24

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

the Make.sh script is the one that is in the /mnt/HD_a2/ffpbuildenv/source/ directory and it is the script that is used to make the package in fonz environment.

the python path is that you told me yesterday...at least that directory exist in my ffp environment.

next requirements are alredy installed on my ffp, so I will try to install duplicity using its own command before the funpkg -i.

I don't know if this is a good way to do it, but I have not any other idea......

Offline

 

#16 2011-05-31 14:05:01

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 678

Re: understanding ffp and compiling packages in a zyxel nsa-221

next requirements are alredy installed on my ffp, so I will try to install duplicity using its own command before the funpkg -i.

Ah! Now I understand what you are doing.
Normally the './configure && make && make install' triplet will build a package, and install it in the local filesystem. Installation means, put the binaries in /bin or /usr/bin, put the documentation somewhere else, create and run some scripts to change environment variables, ...

In case you want a redistributable FFP package this is unwanted. Then you want to put all the files in a tarball, with a script to do all installing work. So fonz created a set of scripts to translate the 'make install' part to something which generates an funpkg compatible tarball.
But in your case there is no need to do this extra step, I suppose. It's fine as the package just installs itself on your local filesystem, so you can just use the package native installer (setup.py in this case), and all you have to care for is the unorthodox paths in FFP, by applying --prefix, and maybe manually editing script headers and configuration files.

Offline

 

#17 2011-05-31 15:55:00

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

I GOT IT!!!!


FOR DUPLICITY:
yes, I have installed all the necessary packages (librsync, boto, python 2.5, Gnu...., gnu.....,pexpect and ncftp) with funpkg -i command, then
I have modified the header in these source files of duplicity: setup.py, duplicity.py, rdiff.py , changing the original "#!/usr/bin/env python" with "#!/ffp/bin/python2.5".

At the end I used this commands:

python2.5 setup.py install --prefix=/ffp
export PYTHONPATH='/ffp/lib/python2.x/site-packages/'
/ffp/bin/duplicity -V    #<---this just tells you the version I think

then a little studying about commands for duplicity
and.....

backup works!

tried also restoring and works fine.
I advise for others that want to use this application: when you want to restore your backup, if you have backupped them like me on a remote server (an ftp server in my case),
you have to download on local drive the backup and then restore from there. Duplicity doesn't restore from remote url. Maybe this can save some times to you.

If needed I have the ncftp 3.2.5. well compiled: I don't know where to put it. if someone want it just email me.
Thank you Mijzelf for explanation and help.

Offline

 

#18 2011-05-31 15:57:46

bellofresco
Member
Registered: 2011-05-30
Posts: 29

Re: understanding ffp and compiling packages in a zyxel nsa-221

...I forgot...next steps are make printer and scanner work....if I will need I will ask your help again...;-)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB