Modify Startup Script on Iomega/Lenovo ix4-300d NAS

We want our installed applications to be started whenever we start or restart our NAS without having to log in with ssh and start the service manually. This can be done by creating a “Startup” script and telling your NAS to execute it every boot/reboot. Then we can add as many services as we want.

Requirements

!!! Doing this will void your warranty !!!
!!! Do this on your own risk, this may break your NAS !!!

– SSH Access(Guide Here)

Creating a Startup Script
Login to your NAS, and create the Startup script “init.opt.sh”:

nano /opt/init-opt.sh

Paste this code in your startup script

#!/bin/sh
rm /opt/init-opt.log
echo "Last bootup:" >> /opt/init-opt.log
date >> /opt/init-opt.log
echo "Wait one minute, so that the storage pool 
is mounted" >> /opt/init-opt.log
sleep 1m
# Services after this line

# Services before this line
sleep 360d
reboot

Save (CTRL+O and ENTER) and exit (CTRL+X), now make the file executable:

chmod +x /opt/init-opt.sh

now make a new file “editconfig.sh” :

nano /opt/editconfig.sh

and paste this code in your “editconfig.sh”:

#!/bin/sh
mknod -m0660 /dev/loop3 b 7 3
chown root.disk /dev/loop3
mkdir /tmp/apps
mount -o loop /boot/images/apps /tmp/apps
nano /tmp/apps/usr/local/cfg/sohoProcs.xml
sleep 1
umount /tmp/apps
rm /dev/loop3

now save the file (CTRL+O … ENTER) and exit (CTRL+X) and now make the file executable:

chmod +x /opt/editconfig.sh

Now run the script :

/opt/editconfig.sh

(Don’t remove the editconfig file, it is needed in other guides too)

Now select your firmware version below to continue modifying your startup script :

Add code for 3.3.4.29856 and older

now a (nano) editor will open, scroll down and add following lines inside group 1 under mozzyclient like in the screenshot below. you may have to scroll a while:

<Program Name="init-opt.sh" Path="/opt/init-opt.sh">
<SysOption Restart="-1"/>
</Program>

Putty Startup Script

To save the file, hit CTRL+O, then ENTER to write the file (nano should say “wrote 2xx lines”) then hit CTRL+X to exit the editor. If you are a 100% sure your file is correct, restart your Nas. !!!Only restart your NAS when 100% sure the file is correct, pasting this code wrong or editing anything else in this file may/will break your NAS!!!

Add code for 4.0.2.9960 and up

now a (nano) editor will open, scroll down and add following lines inside group 1 before the </Group>:

<Program Name="init-opt.sh" Path="/opt/init-opt.sh">
<SysOption Restart="-1"/>
</Program>

ix4300dpreserveupdate102

To save the file, hit CTRL+O, then ENTER to write the file (nano should say “wrote 2xx lines”) then hit CTRL+X to exit the editor. If you are a 100% sure your file is correct, restart your Nas. !!!Only restart your NAS when 100% sure the file is correct, pasting this code wrong or editing anything else in this file may/will break your NAS!!!

Adding Startup Services
Add the line that’s required to start a daemon to the “init-opt.sh” file. These lines are given at the end of every NAS Service tutorial on this site!

to view the logfile created every time the startup script is executed.

cat /opt/init-opt.log
Startup Script Example
#!/bin/sh
rm /opt/init-opt.log
echo "Last bootup:" >> /opt/init-opt.log
date >> /opt/init-opt.log
echo "Wait one minute, so that the storage pool is mounted" >> /opt/init-opt.log
sleep 1m
###########################
# Services after this line
PATH=$PATH:/opt/bin

#Transmission
/opt/bin/transmission-daemon --config-dir /mnt/pools/A/A0/Downloads/config/transmission/ --allowed *.*.*.* >> /opt/init-opt.log
echo "Transmission Started " >> /opt/init-opt.log

#Sabnzbd
/opt/bin/python2.6 /mnt/pools/A/A0/Downloads/.apps/sabnzbd/SABnzbd.py --server 0.0.0.0 --daemon
echo "SABnzbd Started" >> /opt/init-opt.log

#Couchpotato
/opt/bin/python2.6 /mnt/pools/A/A0/Media/.Apps/CouchPotatoServer/CouchPotato.py --data_dir /mnt/pools/A/A0/Media/.Apps/_config/couchpotato/ --daemon
echo "Couchpotato Started" >> /opt/init-opt.log

#Sickbeard
/opt/bin/python2.6 /mnt/pools/A/A0/Media/.Apps/Sick-Beard/SickBeard.py --daemon
echo "Sickbeard Started" >> /opt/init-opt.log

#Minecraft
PATH=$PATH:/mnt/pools/A/A0/Downloads/minecraft/ejre1.7.0_21/bin
export PATH
cd /mnt/pools/A/A0/Downloads/minecraft/mc
java -Xms256M -Xmx512M -jar minecraft.jar nogui
echo "Minecraft Started" >> /opt/init-opt.log

# Services before this line
###########################
sleep 360d
reboot

24
Leave a Reply

Leave a Reply

  Subscribe  
newest oldest most voted
Notify of
Guido Verholen
Guest
Guido Verholen

Hi,
I followed the instructions and it went well until I wanted to change the startup file, there is no “nano” folder
I have an X2 instead of a X4.

grt, Guido verholen(Belgium)

Nick Wood
Guest

Hi Steven

I was attempting to do this and when I went to say I noticed the filename was sohoprocs.xml so I decided to not save my changes.

Running /opt/editconfig.sh, the file is now empty… Have I totally screwed something up?

Nick Wood
Guest

root@NAS:/# /opt/editconfig.sh << First time open, CTRL+X, N to save changes
root@NAS:/# /opt/editconfig.sh << Empty File Now?
mkdir: cannot create directory `/tmp/apps': File exists
mount: could not find any free loop device
umount: /tmp/apps: not mounted

rmilyard
Guest

Looks like my programs aren’t starting up after reboot. I can start them myself.

#!/bin/sh
rm /opt/init-opt.log
echo “Last bootup:” >> /opt/init-opt.log
date >> /opt/init-opt.log
echo “Wait one minute, so that the storage pool
is mounted” >> /opt/init-opt.log
sleep 1m
# Services after this line
#Sabnzbd
/opt/bin/python2.6 /mnt/pools/A/A0/Downloads/.apps/sabnzbd/SABnzbd.py –server $
echo “SABnzbd Started” >> /opt/init-opt.log
#Couchpotato
/opt/bin/python2.6 /mnt/pools/A/A0/Downloads/.apps/CouchPotatoServer/CouchPotat$
echo “Couchpotato Started” >> /opt/init-opt.log
#Sickbeard
/opt/bin/python2.6 /mnt/pools/A/A0/Downloads/.apps/Sick-Beard/SickBeard.py –da$
echo “Sickbeard Started” >> /opt/init-opt.log
# Services before this line
sleep 360d

Marius
Guest
Marius

In the last firmware update (4.x) I think it is LEVEL 2 where you have to add

umair
Guest
umair

I have PX-300D running version 4.1.108.32627. When I run /etc/editconfig.sh and modify the XML under Group Level 1, paste the new program …i am unable to save the sohoProcs.xml doing CTRL+O -> Enter. i get the following message: “Error writing /tmp/apps/usr/local/cfg/sohoProcs.xml: Read-only file system” .

Dagus
Guest
Dagus

Hello, I think I bricked It. I followed the instructions above (copy and pasted.) I cannot access the nas any more–web access, share or ssh. I rebooted the nas, it goest through disk configuration, displays the ip address and time. I tried to press the arrow keys but it doesn’t switch displays. When I try to access the webgui, it stuck at “processing” and the nas display goes blank. The firmware is 4.1.114.33421.

Please, is there a way to revert back or re-image the firmware?
Thank you!

Dagus
Guest
Dagus

I managed to ssh into the nas while it was booting. While having the xml file opened in nano, I somehow prevented something to execute and the box booted fine. I reverted the changes and reboot. NAS is back to normal now.
Thanks.

Yury
Guest
Yury

Hi Steven! After modifications of the startup script my IX4-300d NAS hangs on 75% load. Only ping, no shares, no web or ssh access. Is it possible reset to factory defaults any way?

Job
Guest
Job

I am trying to run this on PX6-300d.

I login with root user, download scripts, its ok.
When I run, I could not write config, and then run step by step to check.

I get “mount: warning: /tmp/apps seems to mounted read-only”.

Whats is wrong?

May be its not compatible with px6-300d?

Thanks

Job

Wim Matthijs
Guest
Wim Matthijs

Awesome blog and script, kudoz to that! So i recently FOUND a broken PS3 on the street, it had a corrupted file system, formatted it and reinstalled fresh PS3 OS, works like a charm. I want to use a popular way of hosting PS3 games on my old ix-400d NAS. There is a tool called PS3netsrv that does that job. I have the tool up and running on the NAS? But for some annoying reason it won’t start up with the script! weird because if ssh into the NAS after boot and bash init-opt.sh it DOES work… my script :… Read more »