Thursday, September 28, 2017

warning: script 'startupssrv' missing LSB tags and overrides

Development for Embedded systems running Linux requires that your PC has one of Linux based distros installed. And if you are Linux user you might get in question while buying UPS compatible with Linux. There are some solutions from APC, but searching further you can find French company Legrand which has nice devices supplied with Linux utilities suitable for advanced usage scenarios. Legrand devices is cheaper, but looks well made.
UPS Communicator is one of the tools from Legrand. It is free, but has only command line interface. After installing UPS Communicator you will notice lot of errors coming from insserv Linux tool that calculate the dependencies between all init scripts.
$ sudo /usr/lib/insserv/insserv -n
insserv: warning: script 'K20startupssrv' missing LSB tags and overrides
insserv: warning: script 'startupssrv' missing LSB tags and overrides
insserv: There is a loop between service plymouth and urandom if started
insserv:  loop involving service urandom at depth 4
insserv:  loop involving service hwclock at depth 3
insserv: There is a loop between service startupssrv and udev if started
insserv:  loop involving service udev at depth 1
insserv: There is a loop at service startupssrv if started
insserv: There is a loop at service plymouth if started
insserv: Starting startupssrv depends on plymouth and therefore on system facility `$all' which can not be true!
insserv: Starting startupssrv depends on plymouth and therefore on system facility `$all' which can not be true!
insserv: Starting startupssrv depends on plymouth and therefore on system facility `$all' which can not be true! 
I spent some time trying to figure out the reason of these notifications. The problem was missing hash symbol in UPS Communicator script header LSB fields

Add 3rd hash symbol before BEGIN INIT INFO and run
$ sudo /usr/lib/insserv/insserv -n
again to check the notifications gone.

Monday, February 6, 2017

Nested bash scripts call graph

One time I had to investigate complex build system from proprietary Linux BSP. It consists of many nested bash scripts. Googling through the Internet I found, that there are no ready tools to create bash call tree. But someone suggested to wrap the shell itself by a custom application, which logs who called it and exec the original shell.
Here you can see my implementation of the wrapper
https://github.com/lvitya/bash_wrapper
bash_wrapper produces a colored log of executed scripts. The log also includes call stack for every script.
The code can be easily modified to help investigate complex nested scripts often used by third-parties to build Linux kernel, rootfs and applications, and to pack it into resulted firmware image.