It is currently Wed Sep 18, 2019 12:56 pm
All times are UTC + 8 hours

[HOW TO] Run your own script on system startup

Share your awesome tips and tricks here.

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

Postby rezza » Fri May 18, 2018 2:05 pm

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
rezza
 
Posts: 13
Joined: Wed Apr 05, 2017 8:48 pm

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

Postby father.mande » Fri May 18, 2018 5:06 pm

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.
AS5002T / AS202TE / AS1002T
My Blog specific to my APKG : https://blog.father-mande.ovh/
User avatar
father.mande
 
Posts: 775
Joined: Sat Sep 12, 2015 2:55 am

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

Postby rezza » Thu Jun 14, 2018 3:23 pm

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
rezza
 
Posts: 13
Joined: Wed Apr 05, 2017 8:48 pm

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

Postby father.mande » Thu Jun 14, 2018 10:51 pm

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.
AS5002T / AS202TE / AS1002T
My Blog specific to my APKG : https://blog.father-mande.ovh/
User avatar
father.mande
 
Posts: 775
Joined: Sat Sep 12, 2015 2:55 am

Previous

Return to Tips & Tricks

  • You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot post attachments in this forum
  • Who is online

    Users browsing this forum: No registered users and 4 guests

cron