NUKI 1.2

I hadn't worked on my demo for almost a year NUKI. Today I have time to fix things because there were a lot of things that were not quite good. I added some new functionality. I rearranged the code, with more features so I shortened it and it became clearer.

The main new functionality I introduced is the signal trap. At some point as the demon rotates the dreambox the receiver decides to kill it and thus stops monitoring my process, which in itself is a rather unpleasant moment. And I can't figure out what's going on because the space for logs is ungodly small and I have to make complex schemes with network sharing that I don't care about.. In general, the signal trap is a nice feature of bash scripts to intercept signals from outputs or those sent to them by the kernel via kill say 😉 and thus we can prevent some of the immediate subsequent events. Just insert that SIGKIL or kill -9 it cannot be intercepted and prevented, so is the design in the kernel. It terminates the PID submitted to it directly. Now the corresponding code

#trapping signals I know -9 dosent work but we try it just in case ; )
trap on_exit 0 14 1 2 9 13 15 6 8 4 3 11 5
on_exit () {
make_debug 10 #unexpected error
#reboot now if we hawe trapped signal
reboot -d 0
exit 0

The first line tells us what action to take and at which signals we will intercept more for the signals. man signals 😉 In this case, I am interested in these. As you can see, they lead to a simple function that debugs a message and restarts the receiver. I'm not having lunch, that will lead to the result I expect, because I think all that interferes is killing with kill -9 but nothing prevents it from being tried.

The other drastic changes are the features most things that are repeated by the code I pushed them into functions, that was a little awkward to watch no, that is now de 😉 I had a slight drama with return in bash – I put my return in one function and expect behavior like all other programming languages ​​I know, but it turned out that return returns only integer values ​​and that maximum 2 😀 and I wanted to return my string. There was an ugly pig. The solution to the problem is simple


if [ $T -eq $N ]
 echo "Cam is down! Reboot..."
make_debug 4 # cam is down
echo $rcam

# ---cuted----

#finding real cam1
 rcam1=$(find_cam $cam1)

The first part is the end of my function and through echo I spit out the result. Taking it is elementary with the last line in the upper passage.

Hmmm I think, that this is the interesting part of the code.

I want to thank her for her inspiration the SilMJ0O13UI&feature=related

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti SPAM *