Monday, January 23, 2012

How to run a program at boot on the Iomega Storcenter NAS


This tutorial uses unsupported features of the IOMEGA Storcenter ix4-200d. It worked for me but use it at your own risk! I undertand it works (but still isn't unsupported by IOMEGA) on the ix2 Storcenter as well.
Tutorial tested on IOMEGA Storcenter ix4-200d firmware 3.1.14.995
This post is extracted from a previous post (how to install crashplan on Iomega storcenter). I am planning more tutorials on the Iomega storcenter ix4 and wanted centralize this part in case it needs to evolve with future firmwares...


1. Enable SSH on the NAS
see my other post How to SSH into your Iomega Storcenter




2. Create a script that runs at boot
Iomega OS (EMC LifeLine) does not respect what is inside /etc/rcx.d/. If you have another brand of NAS, chances are that installing the script into /etc/rc2.d/ will result in the script running at boot...
If you already downloaded the scripts to have a command run at boot, you can just add the new command below the one you already have in /opt/init-opt.sh. Just make sure the commands all return immediately (or add a & at the end) so that the script does not get stuck before reaching the last command.

If that the first time you do this, download the scripts:
cd /opt/
wget http://dl.dropbox.com/u/50398581/Storcenter%20add%20on%20boot/editconfig.sh
chmod +x /opt/editconfig.sh
wget http://dl.dropbox.com/u/50398581/Storcenter%20add%20on%20boot/init-opt.sh
chmod +x /opt/init-opt.sh
Now we start editing the XML list of programs that will automatically be started. Run:
/opt/editconfig.sh
You will see lots of Groups. We are going to add one <program> to <group level="1">. We will add:
<program name="init-opt" path="/opt/init-opt.sh">
<sysoption restart="-1"/>
</program>
the scripts content for you reference:
/opt/editconfig.sh
#!/bin/sh
# edit the bootup config of the ix-2
# inspired by http://www.chrispont.co.uk/2010/10/allow-startup-daemons-on-storcenter-ix2-200-nas/
mknod -m0660 /dev/loop3 b 7 3
chown root.disk /dev/loop3
mkdir /tmp/apps
mount -o loop /boot/images/apps /tmp/apps
vi /tmp/apps/usr/local/cfg/sohoProcs.xml
sleep 1
umount /tmp/apps
rm /dev/loop3
/opt/init-opt.sh
#!/bin/sh
# modified from http://techmonks.net/installing-transmission-and-dnsmasq-on-a-nas/
rm /opt/init-opt.log
echo "Last bootup:" >> /opt/init-opt.log
date >> /opt/init-opt.log
#Add your command below
#/etc/init.d/xxxxxx start >> /opt/init-opt.log
while true; do
 sleep 1d
done
Then, you just need to edit editconfig.sh add the command(s) you wish to run after the
#/etc/init.d/xxxxxx start >> /opt/init-opt.log
line!

15 comments:

  1. Some information has dissapeared from your post, check the line: "We are going to add one to . "
    I assume there needs to be something between "to ." :)

    ReplyDelete
    Replies
    1. It was an html escaping issue. Fixed now. Thanks

      Delete
  2. after walking this thread, my ix4 hangs on 75% and wont boot any further..

    ReplyDelete
    Replies
    1. Sorry, no idea. If the NAS won't boot, it is pretty difficult to debug.
      Did you try the init-opt.sh script without any of your commands inside?

      Delete
    2. Hi, I've the same problem on a ix2... Did you manage to solve it ?

      Delete
    3. I got no news from the OP. Let's hope he can get back to us!

      Delete
    4. Check the to make sure the systemoption tag has the trailing slash. Without it the device fails to boot and you must restore to factory

      Delete
  3. Hi, I try every thing (after mounting the drive on my computer):
    change the right,
    create a file init-opt.sh in the /opt directory of the app' partition, but nothing work..., finaly I delete the script

    nb : I am on the new ix2

    ReplyDelete
    Replies
    1. did you run editconfig while being logged (via ssh) on the NAS?

      that's an essential part and it has to be done while being logged on the NAS...

      Delete
  4. the first time yes, the other time I have done the same mounting instruction as it was showed in editconfig.

    I finnaly succeed in with that command:


    ReplyDelete
  5. I suggest using nano as editor instead of vi.

    Vi is giving me an xml error, nano reads and writes the file correctly.

    ReplyDelete
  6. editconfig.sh:
    supplement: "...sysoption restart="-1"/>"

    Downloaded init-opt.sh was in MSDOS file format. The wrong linefeeds made the script unpossible to run. Just "cat init-opt.sh" and copy/paste the lines to another textfile and move it back to "init-opt.sh".

    Additionaly I commentented out this:
    #while true; do
    # sleep 1d
    #done

    My nrpe-start-script started without it. I don't understand the reason for that non-stopping- mechanism.

    But in fact it was really really helpful to me. Thanks a lot for that workaround.
    /jeckle

    ReplyDelete
    Replies
    1. if you comment the while loop, "init-opt.sh" will be call each seconds.

      Delete
  7. THERE IS A BIG PROBLEM THAT IS CAUSING THE DEVICE NOT TO BOOT AFTER IMPLEMENTING THIS ON IX2-DL >>> MISSING CLOSING " / " ON SYSTEMOPTION TAG





    SHOULD BE



    ReplyDelete
    Replies
    1. sorry to hear this caused an issue for you. I'll add the missing / in the tutorial

      Delete