FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
10,342 views 15 comments
by anonymous

Hello,

I reformulate an unanswered question. In order to put in evidence a problem, I reinstalled the RUT955 firmware without keeping the settings. Now there is no custom scripts.

To highlight the problem:

In system > user scripts, simulate a script by writing:

/usr/bin/logger "hello world"
exit 0

The wiki says: "The custom commands are executed once the system init finished."

Reboot the RUT955 and analyse the logread.

We see the message "Hello world" and, after 10 seconds, we see the message:

... Digital relay output off

The custom scripts are started BEFORE the end of the init which could not be normal !

In my case a script (launched by rc.local) set the digital relay on and, just after, a process set the relay off which is inconvenient, isn't it ?

Log at your disposal but you can easily check as me.
rgds,
PS: Jerome knows the problem

2 Answers

0 votes
by
Wiki says that script runs at the end of the startup process. Where did you see system init?

Couldn't you perform specific checks in your script with specific conditions so it can run? Or just use sleep function if you want a delayed execution?
by anonymous


Where did you see system init?

https://wiki.teltonika-networks.com/view/User_Scripts

startup process = init phase

I already checked by adding a delay after the "hello world". The digital output is set to zero after the delay ! I also thought it was the solution but not.

by anonymous
Hello,

I will try on my side and replicate the said problem. Once i am able i will inform our RnD Team regarding this.

Thank you and have a nice day!
Stay Safe

Regards,
Jerome
by

You are running sleep command after your script? Please paste your rc.local here, it will make things more clear

by anonymous

Here we go

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
/usr/bin/logger "hello world"
sleep 300
exit 0

15h05 37 hello world

15h11 10 Digital relay output off

by
Your script logs "hello world" and then waits 300 seconds. Put sleep before logger, not after
by anonymous

Put sleep before logger, not after

I did it: after 300 seconds, "hello world" message and just after "Digital relay output off" sad

by anonymous
With a sleep 600:

15h36 32 hello

15h36 38 Digital ...

Whatever the value of the delay, "hello" is always before "Digital ..."
0 votes
by anonymous

S95done, which is a part of init, executes rc.local, so init will always finish it's process after rc.local finishes.

It is better to write a separate script, for example:

/bin/script.sh

#!/bin/ash

sleep 300

logger "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

Make it executable:

chmod +x /bin/script.sh

Add it in user scripts (rc.local) with an ampersand (&) so script.sh runs in background:

/bin/script.sh &

now rc.local will execute the script and continue with its process as usual because script.sh is running in background and independent of rc.local.

script.sh will wait for 300 seconds and execute logger

by anonymous
What I don't understand is that my custom script, started by the line /xxx/my_script.sh in the rc.local file, starts BEFORE the initialisation of the Digital Output !

My custom script was running correctly with the version 6.05.3 !!!
by anonymous

Put delay inside the script and an ampersand (&) in user scripts, so it goes to background.

User scripts should contain:

/xxx/my_script.sh &

exit 0

by anonymous
you don't answer to my question ...

put a delay is a work around

what is the optimal value for the delay ...

This is illogical but if it is the answer of Teltonika.
by anonymous
When you need to write a more robust script which performs checks whether a specific service is running or not and only then executes what you want it to execute and then you would not need to use a delay in your code.

Firmware / services that are running in the firmware are always a subject to change, your script needs to reflect that.
by anonymous

Could you tell me which service inits the Digital output ?

When we write a user scripts, we are not suppose to know the core of the system. The Rutos gives the opportunity to start scripts with the function system > user scripts, that's all. Do we also learn how openwrt is running ?

Do you know the regression testing ?

by anonymous

Hello,

Could you check this option that is included on our router?



Because from the script you shared it seems you are just restoring the Digital OC Output to your wanted state. 

Kindly verify. 

Thank you

Regards,

Jerome

by anonymous
Hello,

I have this:

Open collector: low

Relay ouput: contact open

4PIN: low level

But regarless the value, my script should set the correct value (after your init ...) !
by anonymous
Hello,

For this request of yours it would require additional analysis and development from our RnD and for that you may contact your sales representative for this such kind of request.

Thank you and have a nice day!

Regards,
Jerome