autorun on TS-509

Discussion about using NAS on Linux and Unix OS.
andbir
Know my way around
Posts: 146
Joined: Wed Oct 22, 2008 2:34 am
Location: Lund Sweden
Contact:

autorun on TS-509

Post by andbir »

I am experiencing difficulties in setting up a working autorun.sh on my TS-509pro

i have created a text file autorun.sh on my mounted /dev/sdx6 and chmodded it +x and subsequently unmounted the device. The file is owned by admin:administrators.

file contents:
----autorun.sh------------
#!/bin/sh
/bin/ln -sf /opt/jre1.6.0_10 /usr/java
/opt/openfire/bin/openfire start
---------------------------

further, the file persists (as expected) through successive reboots, but does not seem to be executed at all. I was somewhat suprised when i first tried this, to find that this file did not previously exist, but continued and created it.

The file executes quite successfully starting my openfire jabber-chatserver on the TS-509, but only when i invoke it manually.

What am I doing wrong - - or should i go about this in an entirely different fashion possibly involving the /etc/rcS_init.d linked to init.d files (how do i make these persist?) or am I missing something?

I am a somewhat accomplished solaris user but have never actually set up neither a sunos nor a linux workstation. Please advise.

Thank you
Andreas Birgerson
Medical Doctor (resident) and DJ
Lund, Sweden

TS-509 pro (4gb ram) 5x2tb RAID5
TVS-1282-i5-16gb; 8x10tb HGST RAID5 + 2x512gb M.2 SSD as cache
User avatar
schumaku
Guru
Posts: 43578
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: autorun on TS-509

Post by schumaku »

Dear Andreas,
All,
Just a comment: Please refrain from permanently installing or storing anything under the root (/), /opt e.g. /opt/jre1.6.0_10 - DOM (Disk on Module [Flash]) respective the disk based firmware mounts and partitions - and ARE NOT intended to install any add-ons, hacks or modz. Ignoring this will bring reliable operations and future firmware updates to various unexpected issues. My personal guess - >99% of the update, root full, and similar issues here in the forum are caused by the "ignorance" of the effective partition and mount structure. Any user data and applications _must_ be stored to the data volume(s), with e.g. /share providing a reliable softlink.

Subsequent creation of softlink or adding an autostart.sh file is fine, and does not cause any issues.


Regards,
-Kurt.
andbir
Know my way around
Posts: 146
Joined: Wed Oct 22, 2008 2:34 am
Location: Lund Sweden
Contact:

Re: autorun on TS-509

Post by andbir »

Kurt,

/opt is not part of the root file system, it resides on disk, in my case /MD0_DATA/.qpkg/optware

at least this is what it looks like after installing ipkg OptWare (via .qkpg)

I installed my jre to /opt/jre1.6.0_10 and created a softlink (which has to be refreshed every reboot) from /usr/java --> /opt/jre1.6.0_10 with the command ln -sf /opt/jre1.6.0_10 /usr/java.

So my java installation only takes up a measly 20 bytes or so in the ram disk structure /usr and the full installation resides on disk.

Still, my question remains, how do i go about actually having my /dev/sdx6/autorun.sh automatically executed at startup? The file is there, flagged +x and persists through reboots but does not seem to get executed.

Thank you
Andreas Birgerson
Medical Doctor (resident) and DJ
Lund, Sweden

TS-509 pro (4gb ram) 5x2tb RAID5
TVS-1282-i5-16gb; 8x10tb HGST RAID5 + 2x512gb M.2 SSD as cache
User avatar
schumaku
Guru
Posts: 43578
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: autorun on TS-509

Post by schumaku »

Hello again,

With /opt on e.g. MD0_DATA the installation part is fine, please carefully check on the running system later, that no other files show up in the other partitions.

Here the autorun.sh information for all x86 based QNAP NAS, like the TS-509:

Code: Select all

# mount /dev/sdx6 -t ext2 /tmp/config
# cd /tmp/config
# ls
BOOT_COUNT            board_level_test.cfg  uLinux.conf
autorun.sh*           lost+found/
# vi autorun.sh
...edit and save the file...
# umount /tmp/config
Enjoy,
-Kurt.
User avatar
schumaku
Guru
Posts: 43578
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: autorun on TS-509

Post by schumaku »

Updated the Wiki for the x86 NAS - autorun.sh -> http://wiki.qnap.com/wiki/Autorun.sh
zakhounet
Getting the hang of things
Posts: 53
Joined: Mon Sep 22, 2008 9:45 pm

Re: autorun on TS-509

Post by zakhounet »

I am having the same problem, I am trying to automaticly launch the mediaplayer Wizd,
therefore i have created the following autorun.sh :

#!/bin/sh

/share/MD0_DATA/.qpkg/Optware/etc/init.d/wizd start


done with nano, then chmod +x :

[/tmp/config] # ll
drwxr-xr-x 3 admin administ 1.0k Dec 1 23:11 ./
drwxrwxrwx 7 admin administ 1020 Dec 1 23:58 ../
-rw-r--r-- 1 admin administ 2 Dec 1 23:33 BOOT_COUNT
-rwxr-xr-x 1 admin administ 63 Dec 1 23:38 autorun.sh*
-rw-r--r-- 1 admin administ 445 Nov 11 10:00 board_level_test.cfg
drwx------ 2 admin administ 12.0k Sep 24 12:32 lost+found/
-rw-r--r-- 1 admin administ 5.4k Dec 1 23:30 uLinux.conf


then umount /tmp/config, but the autorun.sh doesn't launch automaticly after the reboot.
If I launch it manually after mounting /tmp/config then it's ok. Any advise will be more than welcome.
Qnap TS559 10To
andbir
Know my way around
Posts: 146
Joined: Wed Oct 22, 2008 2:34 am
Location: Lund Sweden
Contact:

Re: autorun on TS-509

Post by andbir »

i am thinking maybe we experience this because the autorun.sh gets executed before all of the disksystems are mounted. so i am thinking of linking in whatever i want executed with a link in /etc/rcS.d with late priority or something. i just added /bin/echo xxx>/myfile to the top of my autorun.sh to see if at least that line gets executed (root "/" should probably exist, even before all disksystems are mounted, right?)

will let you know what i find out, in this thread.

cheers
Andreas Birgerson
Medical Doctor (resident) and DJ
Lund, Sweden

TS-509 pro (4gb ram) 5x2tb RAID5
TVS-1282-i5-16gb; 8x10tb HGST RAID5 + 2x512gb M.2 SSD as cache
User avatar
Don
Guru
Posts: 12289
Joined: Thu Jan 03, 2008 4:56 am
Location: Long Island, New York

Re: autorun on TS-509

Post by Don »

No, the disk systems are mounted when autorun.sh is executed. I have it running on my 509 and 209s without any problems. What I do recommend doing is to set up your autorun.sh file as a link to a file on your share. This way when you have to make changes you do not have to mount and umount the flash file systems.

Any scripts you use have to be referenced by the full path and any files referenced within the scripts also should use full paths.

Make sure the autorun.sh is executable.

What did you use to create the autorun.sh file? Hope it was a Linux editor and not a Windows editor which will add carriage returns to every line and cause script processing to fail.
Use the forum search feature before posting.

Use RAID and external backups. RAID will protect you from disk failure, keep your system running, and data accessible while the disk is replaced, and the RAID rebuilt. Backups will allow you to recover data that is lost or corrupted, or from system failure. One does not replace the other.

NAS: TVS-882BR | F/W: 5.0.1.2346 | 40GB | 2 x 1TB M.2 SATA RAID 1 (System/VMs) | 3 x 1TB M.2 NMVe QM2-4P-384A RAID 5 (cache) | 5 x 14TB Exos HDD RAID 6 (Data) | 1 x Blu-ray
NAS: TVS-h674 | F/W: 5.0.1.2376 | 16GB | 3 x 18TB RAID 5
Apps: DNSMasq, PLEX, iDrive, QVPN, QLMS, MP3fs, HBS3, Entware, DLstation, VS, +
zakhounet
Getting the hang of things
Posts: 53
Joined: Mon Sep 22, 2008 9:45 pm

Re: autorun on TS-509

Post by zakhounet »

Don,

Thanks for your answer.
Don wrote: No, the disk systems are mounted when autorun.sh is executed. I have it running on my 509 and 209s without any problems. What I do recommend doing is to set up your autorun.sh file as a link to a file on your share. This way when you have to make changes you do not have to mount and umount the flash file systems.

Any scripts you use have to be referenced by the full path and any files referenced within the scripts also should use full paths.
My autorun.sh is only two lines with the full path :
#!/bin/sh
/share/MD0_DATA/.qpkg/Optware/etc/init.d/wizd start


Make sure the autorun.sh is executable.

I made a chmod +x
[/tmp/config] # ll
drwxr-xr-x 3 admin administ 1.0k Dec 1 23:11 ./
drwxrwxrwx 7 admin administ 1020 Dec 1 23:58 ../
-rw-r--r-- 1 admin administ 2 Dec 1 23:33 BOOT_COUNT
-rwxr-xr-x 1 admin administ 63 Dec 1 23:38 autorun.sh*
-rw-r--r-- 1 admin administ 445 Nov 11 10:00 board_level_test.cfg
drwx------ 2 admin administ 12.0k Sep 24 12:32 lost+found/
-rw-r--r-- 1 admin administ 5.4k Dec 1 23:30 uLinux.conf


What did you use to create the autorun.sh file? Hope it was a Linux editor and not a Windows editor which will add carriage returns to every line and cause script processing to fail.
I have use "NANO" from the CLI (putty SSH)
I am stuck ...
Qnap TS559 10To
User avatar
Don
Guru
Posts: 12289
Joined: Thu Jan 03, 2008 4:56 am
Location: Long Island, New York

Re: autorun on TS-509

Post by Don »

My autorun.sh is only two lines with the full path :
#!/bin/sh
/share/MD0_DATA/.qpkg/Optware/etc/init.d/wizd start
What about wizd? Are full paths used within it?
Use the forum search feature before posting.

Use RAID and external backups. RAID will protect you from disk failure, keep your system running, and data accessible while the disk is replaced, and the RAID rebuilt. Backups will allow you to recover data that is lost or corrupted, or from system failure. One does not replace the other.

NAS: TVS-882BR | F/W: 5.0.1.2346 | 40GB | 2 x 1TB M.2 SATA RAID 1 (System/VMs) | 3 x 1TB M.2 NMVe QM2-4P-384A RAID 5 (cache) | 5 x 14TB Exos HDD RAID 6 (Data) | 1 x Blu-ray
NAS: TVS-h674 | F/W: 5.0.1.2376 | 16GB | 3 x 18TB RAID 5
Apps: DNSMasq, PLEX, iDrive, QVPN, QLMS, MP3fs, HBS3, Entware, DLstation, VS, +
zakhounet
Getting the hang of things
Posts: 53
Joined: Mon Sep 22, 2008 9:45 pm

Re: autorun on TS-509

Post by zakhounet »

Don, first of all thank you to taking care of my issue.

I have done two things, first i had the complete path into the wizd script :

#!/bin/sh

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/opt/sbin:/opt/etc:/opt/share/wizd:/opt/lib/ipkg/info:/opt/share/wizd/skin:/share/Films_HD

DAEMON=/opt/sbin/

NAME=wizd
DESC="mediaserver"

test -x $DAEMON || exit 0

start() {

echo -n "Starting $DESC: $NAME"

/share/MD0_DATA/.qpkg/Optware/sbin/wizd
}

stop() {

echo -n "Stopping $DESC: $NAME"

killall wizd

}
case "$1" in
start)
start
;;

stop)
stop
;;
*)
echo "Usage $0 {start|stop}"
exit 1
esac
exit 0



But still not working. I have also added into my autorun.sh an export PATH directive :
New autorun.sh
#!/bin/sh

export PATH=$PATH:/share/MD0_DATA/Software/Java/j2sdk1.4.2_18/bin:/opt/etc:/opt/share/wizd

/share/MD0_DATA/.qpkg/Optware/etc/init.d/wizd start


But stil after reboot not working and even worth the echo $PATH return the original path ????

Could you send me an example of an autorun.sh working on your TS-509 ?
Last edited by zakhounet on Wed Dec 03, 2008 8:59 pm, edited 2 times in total.
Qnap TS559 10To
andbir
Know my way around
Posts: 146
Joined: Wed Oct 22, 2008 2:34 am
Location: Lund Sweden
Contact:

Re: autorun on TS-509

Post by andbir »

Yes my "/bin/echo xxx>/myfile " test line at the start of my autorun.sh got executed, and so did the link command, judging from my latest reboot. Wee!

Yes of course I am using a unix text editor (vi) and of course I use full paths on all lines of the autorun.sh but i think Don is quite right, the program i am trying to launch (Openfire jabber server) does not use full paths, so i will have to do something about this, shouldn't be too difficult.

On a sidenote, I was quite happy to see that my autorun.sh file survived the firmware update i just did (ts509-1128)

Cheers,
Andreas Birgerson
Medical Doctor (resident) and DJ
Lund, Sweden

TS-509 pro (4gb ram) 5x2tb RAID5
TVS-1282-i5-16gb; 8x10tb HGST RAID5 + 2x512gb M.2 SSD as cache
zakhounet
Getting the hang of things
Posts: 53
Joined: Mon Sep 22, 2008 9:45 pm

Re: autorun on TS-509

Post by zakhounet »

andbir, Don,

any ideas why the export PATH is not working ?
Qnap TS559 10To
andbir
Know my way around
Posts: 146
Joined: Wed Oct 22, 2008 2:34 am
Location: Lund Sweden
Contact:

Re: autorun on TS-509

Post by andbir »

i think you need to include /bin:/sbin:/usr/bin:/usr/sbin in your path when you set it in your script. chances are your wizd program (whatever this is?) needs to be able to find some executables in these directories also.

whether you export the path or not is probably moot; it the path needs to exist in the context of your executing your wizd, and when autorun.sh is finished this line of execution ends and there is no actual target for your export command.. (correct me if i am wrong, i am no unix/linux expert)
Andreas Birgerson
Medical Doctor (resident) and DJ
Lund, Sweden

TS-509 pro (4gb ram) 5x2tb RAID5
TVS-1282-i5-16gb; 8x10tb HGST RAID5 + 2x512gb M.2 SSD as cache
andbir
Know my way around
Posts: 146
Joined: Wed Oct 22, 2008 2:34 am
Location: Lund Sweden
Contact:

Re: autorun on TS-509

Post by andbir »

oh i think you actually did set the path to include /bin:/sbin etc now when i read it again from the top.

but where do you expect the output from your ECHO command to go? you need to redirect it to a file if you want to be able to examine the output.
also you might need to sourcepath it (

Code: Select all

/bin/echo xxxx > /mydebug.txt
)
Andreas Birgerson
Medical Doctor (resident) and DJ
Lund, Sweden

TS-509 pro (4gb ram) 5x2tb RAID5
TVS-1282-i5-16gb; 8x10tb HGST RAID5 + 2x512gb M.2 SSD as cache
Post Reply

Return to “Linux & Unix (NFS)”