As a Windows-born user I was kind of surprised, that writing Linux version of
autoexec.bat isn't as easy task as it is under Windows (or formerly, under DOS, from which Windows has inherited this solution). Anyway, here is an example on how to execute bash script during every startup of QNAP machine.
Autorun script resides in in flash memory of QNAP and thus you need an extra script to edit it:
mount -t ext2 /dev/mtdblock5 /tmp/config nano /tmp/config/autorun.sh umount /tmp/config
This script mounts flash memory, opens
autorun.sh in nano and unmounts flash memory after closing nano.
This might be a little bit unhandy, as you have to manually write down your script for the first time. For this (or any other reason) you may copy flash memory script to local folder with following script:
#!/bin/sh mount -t ext2 /dev/mtdblock5 /tmp/config cp /tmp/config/autorun.sh /share/Bash/autorun umount /tmp/config
Then you may edit it at any time (in
/share/Bash/autorun location in my case) and finally upload it back to flash memory with this script:
#!/bin/sh mount -t ext2 /dev/mtdblock5 /tmp/config cp /share/Bash/autorun/autorun.sh /tmp/config/ umount /tmp/config
I'm using solution discussed in this article (along with fix to QNAP mixing USB shares, discussed here) to bring my own backup solution to QNAP. This is because backup solutions currently available in QNAP are poor. However, there are rumors, that with new firmware, QNAP should offer something much better so these two articles may soon become useless to the QNAP community. But, until then, they work like a charm.
Note: I personally hate vi, which is why I used nano here. nano isn't orignally installed on your QNAP (most probably). Consult "Optware and other QPKG packages for QNAP" post on how to get it (along with some other usefull stuff missing on most QNAPs).