We want our installed applications to start automatically whenever the NAS powers on or reboots, without the need to manually log in via SSH and launch each service. Automating this process ensures that your custom services are always running and available, providing a seamless experience without extra effort on your part.
This can be achieved by creating a dedicated “Startup” script and configuring your NAS to execute it on every boot or reboot. By using this method, you can easily manage multiple services, adding or removing them from the script as needed, so your NAS always launches exactly the applications you want without any manual intervention.
IMPORTANT WARNINGS:
-
This procedure will void your warranty.
-
Proceed at your own risk—incorrect steps may break your NAS.
-
Make sure you fully understand the instructions before continuing.
Prerequisites
-
You must have SSH access enabled on your NAS. If you haven’t done this yet, follow this SSH Access Guide first.
Create the Startup Script (init-opt.sh
)
-
Log in to your NAS via SSH using your preferred terminal (PuTTY, Terminal, etc.).
-
Create and open the startup script file in the nano editor:
-
Paste the following script into the editor:
-
This script clears the previous log, records the current boot time, waits one minute to ensure your storage pool is fully mounted, and then runs your services (which you will add below).
-
After running your services, it waits a long time (360 days) and then reboots the NAS. This prevents the NAS from restarting repeatedly unless you manually reboot it earlier.
-
-
Save and exit nano:
-
Press
CTRL + O
to write the changes, thenENTER
to confirm. -
Press
CTRL + X
to exit nano.
-
-
Make the script executable:
Create and Run the Configuration Editing Script (editconfig.sh
)
This script allows you to edit the NAS’s internal configuration so the startup script runs automatically on boot.
-
Create and open the file:
-
Paste the following code:
-
This script mounts the internal apps configuration file so you can edit it.
-
-
Save and exit nano (
CTRL + O
,ENTER
,CTRL + X
). -
Make the script executable:
-
Run the script to open the config file:
Modify Startup Configuration Based on Your Firmware Version
After running /opt/editconfig.sh
, a text editor opens the file sohoProcs.xml
. Here you will add instructions for the NAS to run your startup script automatically.
For Firmware 3.3.4.29856 and Older
-
Scroll down inside the editor until you find Group 1, under the tag
<Group>
and inside the<mozzyclient>
section. -
Add the following lines inside Group 1, exactly like this:
-
Save and exit nano (
CTRL + O
,ENTER
,CTRL + X
). -
WARNING: Only restart your NAS if you are 100% sure the file is correct. Incorrect changes to this file can break your NAS.
For Firmware 4.0.2.9960 and Newer
-
Scroll down inside the editor to Group 1.
-
Add the following lines inside Group 1, just before the closing
</Group>
tag: -
Save and exit nano (
CTRL + O
,ENTER
,CTRL + X
). -
WARNING: Only restart your NAS if you are 100% sure the file is correct. Incorrect editing can break your NAS.
Add Startup Services to Your Script
Now that your startup script will run at boot, you can add the commands to start your desired services.
-
Open your startup script:
-
Add your service start commands after the comment line
# Services after this line
. For example:
Save and exit nano (CTRL + O
, ENTER
, CTRL + X
).
Check the Startup Log
Every time your NAS boots and runs your startup script, it writes status messages to a log file. To check what happened during startup, use:
This log will help you verify whether your services started correctly.
Final Notes
-
Never remove or modify default system applications listed in your NAS, as that may cause system instability.
-
Only reboot your NAS after verifying your configuration changes are correct.
-
Keep the
editconfig.sh
script for future edits or guides.
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)
“nano” is the program that allows you to edit text files, you can change every “nano” by “vi” or “vim”, these are text editors but are a bit different:
-to insert text => type i then type your text
-to save => ESC -> :wq -> enter
you can also try to install “nano” by using one of the following lines:
– /opt/bin/ipkg install nano
– apt-get install nano
always double check your files before restarting, wrong code can break your Nas!!
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?
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
The editconfig.sh should not be empty after execution, this file should be executed after every update to restore your servers. I would recommend removing your files and try this guide again, i found a small fault in the guide… this may be the problem.
Sorry, the editconfig.sh isn’t empty, but the sohoProcs file that it generates doesn’t populate with any values since running it that first time. It’s blank when I run /opt/editconfig.sh for some reason
sounds like the editconfig has a wrong path or filename and created a new file, paths and filenames are case sensitive… did you copy-paste the file or just typed it? check if your editconfig is the same as mine.
I copy pasted everything listed above.
Thought I’d try and start over so I deleted the init-opt.sh and the editconfig.sh, and also removed /tmp/apps
http://goo.gl/cWBLMV
root@NAS:/opt# rm editconfig.sh
root@NAS:/opt# rm init-opt.sh
root@NAS:/opt# cd ..
root@NAS:/# nano /opt/init-opt.sh
root@NAS:/# chmod +x /opt/init-opt.sh
root@NAS:/# nano /opt/editconfig.sh
root@NAS:/# chmod +x /opt/editconfig.sh
root@NAS:/# /opt/editconfig.sh
mount: could not find any free loop device
umount: /tmp/apps: not mounted
root@NAS:/# /opt/editconfig.sh
mkdir: cannot create directory `/tmp/apps’: File exists
mount: could not find any free loop device
umount: /tmp/apps: not mounted
root@NAS:/#
I should’ve just saved the file the first time it generated 🙁
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
is the script executed? check if there is a “init-opt.log” file, also did you do the chmod +x (add execute rights)? you can try “chmod 777 /opt/init-opt.sh”. also are you logged in as root?
I think so. Following guide. I just keep having issues. Not sure why because first time I did this wasn’t near as hard.
In the last firmware update (4.x) I think it is LEVEL 2 where you have to add
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” .
are you logged in with a admin account, you could try sudo or su?
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!
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.
I’m glad you managed to fix your NAS, havn’t tested the latest firmware myself yet but it should still work.
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?
you should look trough the comments, there’s been someone with the same problem who fixed it.
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
this tutorial is for ix4-300d, i haven’t tested with the px6-300d.
Just updated to 4.1.306.34329 without problems. go ahead
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 :
#!/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
#start ps3netsrv
echo “attempting to start ps3netsrv”
cd /mnt/pools/A/A0/ps3netserv/webMAN/Projects/ps3netsrv
nohup ./ps3netsrv /mnt/pools/A/A0/ps3netserv/ps3netsrv &
Services before this line
sleep 360d
reboot
see anything wrong? any tips to get it running on startup?
I know it might have been a while since anybody posted in this thread, but still any suggestion is welcome 🙂
cheers,
Wim
hmm, you could try redirecting the output of nohup to the logfile and see what the actual error is.
When executing editconfig.sh, mknod is returning an invalid mode message – I’ve checked the /dev directory and the loop3 node is not being created. Until I know what’s going on, I’m not going near a restart – I’d rather not brick my NAS!