Page 3 of 3

Re: [HOW TO] Run your own script on system startup

PostPosted: Fri May 18, 2018 2:05 pm
by rezza
hello.

I manually execute my sh script correctly. but after copying it inside usr/local/etc/unit.d and rename it with SXXghhhh.sh, it won t run at NAS start-up...
Can someone help me ?

thanks

rezza

Re: [HOW TO] Run your own script on system startup

PostPosted: Fri May 18, 2018 5:06 pm
by father.mande
Hi,

For all problem with init scripts remember :

init script are executed by init so not with all the capabilities of a shell and without a full shell environment
... so be sure to use Full Path-name, to set the full environment (all variables, alias, etc.), to be sure that program you use are present ... ex. if you target an APKG (Entware bash for ex.) ... ALL APKG are started AFTER the end of the init script series ... so not ready when init script start ... and a little more (so think to set debug (like -x/-v/-f by set instruction in shell) and log all stderr stdout )

It's same for other O.S. managed task (ex. cron @reboot for ex., at command, etc. )

summary :
do as if NO environment exist when you start your script ...
always verify that target (for ex. Python apkg or what-else) are already enable and active (so best is to generate a loop on task of file or link or ... but as usual not infinite ... use timeout delay and write log message in case )
remember that su (even sudo but a little more difficult to prepare) are provide in A.D.M.

Philippe.

Re: [HOW TO] Run your own script on system startup

PostPosted: Thu Jun 14, 2018 3:23 pm
by rezza
HELLO.

My script (inside init.d) was correctly launched at start-up but prevent the file /usr/etc/emboard.conf to do its normal job. The consequence was that I couldn't apply any hardware energy settings with ADM as well as with SSH.
After removing the script from usr/local//etc/init.d, the problem disappeared...

A possible clue : Inside My script, I used a TCPDUMP function which has been installed with Entware OPKG...

Any idea ?

thanks

regards

RezzA

Re: [HOW TO] Run your own script on system startup

PostPosted: Thu Jun 14, 2018 10:51 pm
by father.mande
Hi,
rezza wrote:HELLO.
My script (inside init.d) was correctly launched at start-up but prevent the file /usr/etc/emboard.conf to do its normal job. The consequence was that I couldn't apply any hardware energy settings with ADM as well as with SSH.
After removing the script from usr/local//etc/init.d, the problem disappeared...
A possible clue : Inside My script, I used a TCPDUMP function which has been installed with Entware OPKG...
Any idea ?
thanks
regards
RezzA


First be sure to use full path-name or to add /opt/bin:/opt/sbin in PATH and export it
Second add a loop (not infinite ... but for a correct delay) to test if Entware is up or not yet
... ex. use apkg to test the status or test if path to /opt/bin/tcpdump or /opt/bin/opkg exist ... add a small delay (to be sure all is set up) ... then run the command ...

Philippe.