Ergebnis 1 bis 9 von 9

Thema: How to run your own scripts automatically on NAS4210

  1. #1

    Beitrag How to run your own scripts automatically on NAS4210

    To the readers of this document:

    A few days ago I bought the ICY BOX IB-NAS4210. Thinking, I could just do what others already did with the 4220 I was negatively surprised, I couldn't. Biggest problem was that I didn't find any way to start my own stuff right after the boot process.

    Important note:
    "after the boot process" for me means as the last step when executing the scripts in /etc/rc.d which seems to be before all the sausalito parts get startet.

    In one of the operating system bootup files "/etc/rc" in line 177 you will find the part that starts all the scripts in /etc/rc.d:
    Code:
    "for i in /system/local/etc/rc.d/*.sh; do"
    --> lastest thing wouls probably be S99adinfinitum.sh

    further down in line 304:
    Code:
    "/usr/sausalito/bin/constructor"
    In this forum you can also read about the spindown problem. I for myself found a solution (it's a workaround, not like the user manual tells you...) but only possible due to running scripts after the boot process. As soon as I do find the time, I'll also publish the rest of what I did. For today it's just this...


    MOST IMPORTANTLY:
    -----------------------------------------------------------------------------------
    No Warranty!!!!!!!


    DESCRIPTION:
    -----------------------------------------------------------------------------------
    Main goal was to get the ICY BOX IB-NAS4210 to start one script located on the mounted hard-disk right after the boot process as part of the boot process. Why? Because having that set up you can easily start/run/do what you want to run on that box by editing that one script on the hard-disk.


    HELP/SOURCES I USED:
    -----------------------------------------------------------------------------------



    PRECONDITIONS/ASSUMPTIONS I made:
    -----------------------------------------------------------------------------------

    • You do have good chances this guide works for you if you try to use it for your ICY BOX IB-NAS4210.
    • You need to have access to it via telnet or SSH. Log in and run "uname" and "cat /proc/version" to see whether that matches what I have here. If it does, your chances that this guide will work are even higher ;-)

    Code:
    # uname -a
    Linux icecap 2.6.15 #129 Mon Jun 23 16:36:38 CST 2008 armv4l unknown
    # cat /proc/version 
    Linux version 2.6.15 (root@jammy-nb.mpc.com) (gcc version 3.4.4) #129 Mon Jun 23 16:36:38 CST 2008
    • Better do all these steps logged in via telnet or ssh and use the version of "vi" on the box to not get into trouble due to different linebreaks (Win vs. Unix vs. ...), etc.
    • For me, it's /mnt/ide4 as the mountpoint of the harddisk and this guide should only be used if the whole setup is equal to mine. Otherwise you need to test and doublecheck much more. If for some reasons /mnt/ide4 isn't YOUR mountpoint then do a search/replace and replace

    Code:
    "/mnt/ide4/"
    with
    Code:
    "$(cat /usr/sausalito/codb/objects/1/Disk.rootdir 2> /dev/null)/"
    or the path you use hard-coded.


    • make sure you're root!
      • root password = admin password (in my case)

    • Check this - should look the same - otherwise you better don't use this guide. What we're looking for is the Ramdisk. It's mtd2 and contains 0x600000 (hex!) Bytes

    Code:
    # cat /proc/mtd
    dev:    size   erasesize  name
    mtd0: 00020000 00020000 "RedBoot"
    mtd1: 00300000 00020000 "Kernel"
    mtd2: 00600000 00020000 "Ramdisk"
    mtd3: 00600000 00020000 "Application"
    mtd4: 00020000 00020000 "VCTL"
    mtd5: 000a0000 00020000 "CurConf"
    mtd6: 00020000 00020000 "FIS directory"

    STEP BY STEP
    -----------------------------------------------------------------------------------
    CREATING THE BACKUP
    -----------------------------------------------------------------------------------
    see http://www.nas-2000.org/mwiki/index...._your_firmware

    CREATING YOUR 'NEW' FIRMWARE
    -----------------------------------------------------------------------------------
    1.) OPENING the currently running firmware:
    also see http://www.nas-2000.org/mwiki/index...._your_firmware
    Here, we'll only use rd.gz and the ImageInfo file
    Log into your box using telnet or SSH
    Code:
    # cd <where rd.gz is>
    # gunzip rd.gz
    # file rd
    rd: Linux rev 1.0 ext2 filesystem data
    # mkdir /mnt/your_rd
    # mount -t ext2 -o loop rd /mnt/your_rd


    2.) ADDING the start script

    Code:
    # cd /mnt/your_rd/etc/rc.d
    # vi S99adinfinitum.sh
    ATTENTION: make sure, you really name the suffix of this script ".sh" like the whole name would now be "S99adinfinitum.sh" for example.


    COPY/PASTE the following lines into S99adinfinitum.sh
    -8<---8<---8<---8<---8<---8<---8<---8<---8<--
    Code:
    #!/bin/sh
    #
    #
    
    # get Mountpoint of harddisk to use
    HD_MNT_POINT=$(cat /usr/sausalito/codb/objects/1/Disk.rootdir 2> /dev/null)
    #HD_MNT_POINT=/mnt/ide4
    
    # some of the packages I saw lie in 'public' but I think this is very low
    # level and hence shouldn't be in 'public' but in 'admin'
    ADINFINITUM=${HD_MNT_POINT}/admin/adinfinitum/adinfinitum.sh
    
    case "$1" in
            start)
                    echo "Starting ADINFINITUM Extention"
                    ${ADINFINITUM} start
            ;;
            stop)
                    echo "Stopping ADINFINITUM Extention"                                            
                    ${ADINFINITUM} stop
            ;;
            forcestart)
                    echo "Starting ADINFINITUM Extention"
                    ${ADINFINITUM} forcestart
            ;;
            *)
                    echo "usage: $0 { start | forcestart | stop }" >&2
                    exit 1
            ;;
    
    esac
    -8<---8<---8<---8<---8<---8<---8<---8<---8<--

    This is what will be executed as one of the latest steps in the boot process of your NAS device.


    3.) ADDING directory and creating user owned script on the hard-disk
    Code:
    # mkdir -p /mnt/ide4/admin/adinfinitum/
    # chown root:users /mnt/ide4/admin/adinfinitum/
    # chmod 775 /mnt/ide4/admin/adinfinitum/
    # vi /mnt/ide4/admin/adinfinitum/adinfinitum.sh
    COPY/PASTE the following lines into adinfinitum.sh
    -8<---8<---8<---8<---8<---8<---8<---8<---8<--
    Code:
    #!/bin/sh
    # NOTE: this is an example, only. Feel free to put in here what you want/need
    
    # Just for emergencies: after rebooting don't start this script
    # for one minute. Worst case is you put something in it which
    # disturbs regular operation If that would happen, you'd be glad
    # to have a few seconds to interrupt 
    
    f [ "$1" = "forcestart" ]
    then
            echo "not waiting starting right away"
    else
            echo "sleeping for 60 seconds"
            echo "parameter 'forcestart' to force this"
            sleep 60
    fi
    
    echo "$(date) ## \$1 was: $1" >> /mnt/ide4/admin/adinfinitum/adinfinitum.log
    -8<---8<---8<---8<---8<---8<---8<---8<---8<--
    Code:
    # chmod 755 /mnt/ide4/admin/adinfinitum/adinfinitum.sh
    4.) CLOSING new firmware to put it into an updatable firmware package
    Code:
    # umount /mnt/your_rd
    # cd <where rd.gz is>
    # gzip rd.gz
    # cd <where rd.gz is>
    # cp /system/ImageInfo ./
    # vi ImageInfo
    CHANGE first line to: UpgradeImages="rd.gz"
    CHANGE is to reduce the 'list' of UpgradeImages to only contain "rd.gz" which we manipulated earlier

    5.) CHECKPOINT: you should now have
    Code:
    # ls -1
    ImageInfo
    rd.gz
    6.) BUILDING THE FIRMWARE-UPDATE package (updating what is on the ramdisk (=rd.gz))
    Code:
    # tar czf ../firm_adinfinitum.tar.gz *
    WARNING:
    You might want to add further files. But make sure that the gzipped file in the end isn't bigger than 5167329 Bytes in case
    mtd2: 00600000 00020000 "Ramdisk"
    (see above) looks like the same for you. 00600000 it's hex and equals to 5167329.


    INSTALLING THE NEW FIRMWARE
    -----------------------------------------------------------------------------------
    The file firm_adinfinitum.tar.gz you can now copy to your computer and use the web interface to use this file as it is as a new firmware version. Using the Internet Explorer might be the best way. While it's uploading don't do too much ... just to reduce risk of ... well whatever could happen.

    After it's done and the device has rebooted you'll have your own script that will be started as one of the latest steps in the boot process and that you can easily use to start what ever you want. That script is (in the example above): /mnt/ide4/admin/adinfinitum/adinfinitum.sh


    READY TO USE PACKAGE
    -----------------------------------------------------------------------------------
    Again: this is on your own risk! It's the version currently running on my 4210 device.

    http://rapidshare.de/files/42238102/...um.tar.gz.html
    Geändert von s|ug (18.01.2009 um 19:10 Uhr)

  2. #2

    Standard

    cool, thanks. I'd like to make this post sticky; did anybody try this and can confirm it?
    mfg,
    vishcompany

    Newbie-FAQ - Linux für Anfänger - forumregeln - Leitfaden
    for our international users: language settings - posting guide - translation service

    Verwechsle niemals Redundanz (RAID1) mit Datensicherheit (backup)!

    Bitte keine supportanfragen per PM. Support gehört ins Forum, dann haben alle etwas davon!

  3. #3

    Standard

    I could not try it, but I was in contact with him and can confirm that he really knows what he is doing.
    So, in my opinion it is absolutely worth making it sticky as this article is of really general interest.

    It should work for other Raidsonic or other maufacturer NAS platforms, too.

    HWguru

  4. #4

    Standard

    This looks great. Your efforts are much appreciated, binningm. Thanks!

  5. #5

    Standard

    awesome guide, thanks many times...

    I'm just curios whether it's possible to install and use SSH (e.g. OpenSSH) server on IB-NAS4210B.

  6. #6

    Standard

    Zitat Zitat von Darkriser Beitrag anzeigen
    awesome guide, thanks many times...

    I'm just curios whether it's possible to install and use SSH (e.g. OpenSSH) server on IB-NAS4210B.
    You can just take the packages (for 4220) from the wiki..

    Extract them, check the contents of the 'init' file to make sure paths are correct etc and run it...

  7. #7

    Standard

    Hello binningm,

    sorry for disturb you regarding your great description above. I try what you describe there and result now in a tar file have only the rd.gz and the ImageInfo file inside. I´m not sure whether this is ok for a firmware update file. Is it not necessary to have all firmware files there included? Sorry for that stupid question ;-)

    Marlit

  8. #8

    Standard

    Yes, I can confirm it.
    A few minutes ago I followed the instruction and did it with succes. Now my copies of /etc/passwd and /etc/group are copied over the original files, making uid and gid on the NAS and my computers identically.

    And to answer marlit: In fact, you only need rd.gz and the ImageInfo in the image.

    Thanks a lot to binnigm!


  9. #9

    Standard

    Hi Ka_jan,

    great that it work. I allready get it running without problems. But now I have a different problem. I tried again to create a rd mount image using file rd. But now I get allways a :

    rd: Linux rev 1.0 ext2 filesystem data (mounted or unclean)


    What means this?

    Regards Marlit

Ähnliche Themen

  1. IB-NAS4220-B Can the bittorrent client automatically search for torrents in a folder?
    Von rudeboymcc im Forum Packages, Tools and Addons
    Antworten: 1
    Letzter Beitrag: 14.11.2008, 14:24
  2. IB-NAS4220-B Getting the ssh-server to run
    Von BoomAM im Forum Packages, Tools and Addons
    Antworten: 19
    Letzter Beitrag: 30.08.2008, 10:47

Stichworte

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •