Webinterface ndas

RomMon

Neuer User
Mitglied seit
29 Aug 2011
Beiträge
105
Punkte für Reaktionen
0
Punkte
16
I'm working on a webinterface for ndas.

The interface is created for one netdisk with up to 16 partitions.
It is working fine for my setup, except see often 'sh: bad number' message in the top of the screen (Probably something in rc.ndas).

Hope others would like to try it also.

The files are for trunk revision 11874 and later.
 

Anhänge

  • rc.ndas.txt
    4.3 KB · Aufrufe: 3
  • ndas.cgi.txt
    2.4 KB · Aufrufe: 3
  • ndas.cfg.txt
    794 Bytes · Aufrufe: 2
Try "sh -x rc.ndas start" (or stat, status ...) to see each command executed by the shell. That should make it easy to identify the line where the bad namber comes from.
 
Looks good to me.

Two minor issues:
1. Please don't use backticks (admin_active=`lsmod | grep ndas_sal | awk '{ print $3 }'`). Use new style "$(...)"
2. module loading: Why not use modprobe instead of "insmod /lib/modules/`uname -r`/kernel/fs/ndas/$MODULE.ko"? Perhaps throwing away the whole loop is okay too and call modprobe 3 times...

Please attach your files to a ticket on freetz.org if you are finished.

Regards
Oliver
 
The module ndas_block depends on ndas_sal and ndas_core, so just do "modprobe ndas_block" and all three modules should be loaded.
If you need module parameter, you can also pass them to modprobe.

Code:
                [ "$LOADED" == "ndas_core" ] && [ -n "$NDAS_DEVICE" ] && OPTIONS="ndas_dev=$NDAS_DEVICE"
                [ "$MODULE" != "$LOADED" ] && insmod /lib/modules/`uname -r`/kernel/fs/ndas/$MODULE.ko $OPTIONS > /dev/null 2>&1
If ndas_core is already loaded, then set OPTIONS to ndas_dev=$NDAS_DEVICE. But if ndas_core is already loaded, then insmod is not executed. So why set OPTIONS?

If you exit anyway on fail, rewrite
Code:
  if condition; then
    good
  else
    message fail
    exit 1
  fi
to
Code:
  if ! condition; then
    message fail
    exit 1
  fi
  good

Instead of
Code:
lsmod | grep ndas_sal | awk '{ print $3 }'
you can write
Code:
awk '$1 == "ndas_sal" { print $3 }' /proc/modules
you redirect output to /dev/null. What happens it something goes wrong?
 
Hi Ralf,

Thanks for the tip with "sh -x", this is really helpful.
The issue is with "rc.ndas status", where it compares with an empty variable:
Code:
+ admin_active=
+ [ -e /mod/etc/ndas.conf ]
+ [  -gt 2 ]
sh: bad number
Applicable part of the script:
Code:
status() {
        admin_active=`lsmod | grep ndas_sal | awk '{ print $3 }'`
        [ -e "$NDAS_CONF" ] && [ "$admin_active" -gt "2" ] && return 0
        return 1
}
Making the variable zero if it is empty should solve this I think.


Code:
                [ "$LOADED" == "ndas_core" ] && [ -n "$NDAS_DEVICE" ] && OPTIONS="ndas_dev=$NDAS_DEVICE"
                [ "$MODULE" != "$LOADED" ] && insmod /lib/modules/`uname -r`/kernel/fs/ndas/$MODULE.ko $OPTIONS > /dev/null 2>&1
If ndas_core is already loaded, then set OPTIONS to ndas_dev=$NDAS_DEVICE. But if ndas_core is already loaded, then insmod is not executed. So why set OPTIONS?
Great catch. It should be:
Code:
                [ "$MODULE" == "ndas_core" ] && [ -n "$NDAS_DEVICE" ] && OPTIONS="ndas_dev=$NDAS_DEVICE"
                [ "$MODULE" != "$LOADED" ] && insmod /lib/modules/`uname -r`/kernel/fs/ndas/$MODULE.ko $OPTIONS > /dev/null 2>&1
I have to look longer to your other remarks and correct the script.

Olistudent,

Found the following about backticks: http://stackoverflow.com/questions/...ts-the-difference-between-command-and-command that is easy to correct.
Will also look into using modprobe i.s.o. insmod.

Edit: (31-03-2014 23:59): modprobe example for passing parameters: https://access.redhat.com/site/docu...ment_Guide/sec-Setting_Module_Parameters.html
 
Zuletzt bearbeitet:
Hi Ralf, Olistudent,

I addressed the recommendations and created a ticket: 2431.

Hope you can have another look to see if I addressed them properly.

Edit: (5-04-2014 02:00):
A question regarding the use of modprobe.
- I tried to see the used parameters with 'modprobe -p <module>' but this didn't give any output.
Is this expected?
Only with 'logread -f' I could observe the parameter was correctly accepted.
 
Zuletzt bearbeitet:
Hi Ralf,

Sorry made a mistake. Should be `modinfo -p <module>` (to late last night).

Code:
# modinfo
BusyBox v1.22.1 (2014-03-23 21:57:45 CET) multi-call binary.

Usage: modinfo [-adlp0] [-F keyword] MODULE

        -a              Shortcut for '-F author'
        -d              Shortcut for '-F description'
        -l              Shortcut for '-F license'
        -p              Shortcut for '-F parm'
        -F keyword      Keyword to look for
        -0              Separate output with NULs

After some googling last night I suspect it should return the parameter capabilities of the module.
But this is probably not implemented by the developer of this module (same for description).

I was looking for a way to determining the parameter I had specified.
 
Hi Ralf,

Using the modinfo <module> on some of the other loaded modules made it clear.
Option -p it is indeed for showing the supported parameter capabilities, but only if the developer included it.
Using modinfo with options (-p, -d, ..) just filters the output just showing the specified option.

E.g. 'modinfo ath_pci' (on 7270v3) shows a number of 'parm' options with a short description.

'-F parm' and '-F parmtype' give different results, where '-F parm' is the same as '-p':
(on 7390, for an module with parm output)
Code:
# modinfo -F parmtype  usb_storage
parmtype:       delay_use:uint
parmtype:       swi_tru_install:uint
# modinfo -F parm  usb_storage
parm:           delay_use:seconds to delay before using a new device
parm:           swi_tru_install:TRU-Install mode (1=Full Logic (def), 2=Force CD-Rom, 3=Force Modem)


For the ndas modules it is just not specified by the developer:
Code:
# modinfo ndas_block
filename:       kernel/fs/ndas/ndas_block.ko
license:        Dual BSD/GPL
author:         Ximeta, Inc.
depends:        ndas_core,ndas_sal
vermagic:       2.6.32.41 mod_unload MIPS32_R2 32BIT

Thanks.
 
Holen Sie sich 3CX - völlig kostenlos!
Verbinden Sie Ihr Team und Ihre Kunden Telefonie Livechat Videokonferenzen

Gehostet oder selbst-verwaltet. Für bis zu 10 Nutzer dauerhaft kostenlos. Keine Kreditkartendetails erforderlich. Ohne Risiko testen.

3CX
Für diese E-Mail-Adresse besteht bereits ein 3CX-Konto. Sie werden zum Kundenportal weitergeleitet, wo Sie sich anmelden oder Ihr Passwort zurücksetzen können, falls Sie dieses vergessen haben.