NUKA 1.2

From almost a year I was working on my demočeto NUKA. Today I have time to fix things because there were a lot of things that were not very well. I added a bit of new functionality. I rearranged the code, with more features and shorted it became more user friendly.

The main new feature that I put a signal trap-. At some point as you rotate the demon dreambox receiver decides to kill him and thus stop monitoring my process, which in itself is quite an unpleasant moment. And there's no way to figure out what is going on because the place is a bit of dirt and logs must do make complex patterns of network shares that you do not want to deal. In general lines signal trap-is a pleasant feature of bash scripts to intercept signals from the outputs or those submitted to them by the kernel through a kill-say 😉 and thus we can prevent some of the immediately subsequent events. Damn that SIGKIL or kill -9 cannot be prehvanat and prevented, that's the core design. It terminated directly submitted his PID. And now the error 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 declares the US as to the action to be taken and in which alerts will we read more about alerts man signals in the case of these 😉 me care. As you can see result in a simple funkciika that makes debugging applications message and restart the receiver. I'm not convinced, that will lead to the outcome that I expect, because I think that everything that hinders is killing with kill -9 but nothing prevents to try.

Other changes are the cardinal features most things that are repeated by the code fill them in functions, It was a bit unsightly not, now that is good, I had a 😉 de drama with a return in bash- – I put on my return in one function and expected behavior as all other familiar programming languages, but it turned out that only return integer values and returns it to a maximum of 2 😀 and I wanted to return the string. There was an ugly pig. The solution 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)

Първата част е края на функцията ми и чрез echo изплювам резултата. Взимането му е елементарно с последния ред в горния пасаж.

Hmmm I think, that's the interesting part of the code.

I want to express my gratitude to the inspiration 😉

leave a reply

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

anti SPAM *