LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Laptop and Netbook (https://www.linuxquestions.org/questions/linux-laptop-and-netbook-25/)
-   -   Need to create a custom init script to override a bug. (https://www.linuxquestions.org/questions/linux-laptop-and-netbook-25/need-to-create-a-custom-init-script-to-override-a-bug-933874/)

edbarx 03-11-2012 06:54 AM

Need to create a custom init script to override a bug.
 
I have the Acer Aspire 7715z laptop which has the long overdue backlight bug. I reported this bug in June 2011 to debian.org and to freedesktop.org but it is still unresolved. However, in the meantime, I found a workaround that I wish to include in an init custom script which need to be run after udev populates /dev. This bug does not manifest itself under kernels < 2.6.38. I am writing because I need to be able to upgrade my linux-image (ie vmlinuz-*) whenever I upgrade my major version of GNU/Linux.

Please, note that this bug is not distribution specific as it is a bug entirely caused by the linux-kernel.

What should I do to create a custom init script and package it as a .deb package to allow dpkg -i to install it?

FrankP 03-14-2012 05:51 AM

Hi, well done for finding the workaround.

A new init script should go in /etc/init.d and needs to respond to the arguments 'start', 'stop' and 'restart'. Then you would create symlinks to it from the runlevel directories rc*.d so that it will be run on startup at its place in the sequence of other scripts.

Alternatively, instead of a new script it might be easier to add your fix as a patch to one of the existing init scripts - then if there was a new version after an upgrade you would re-patch the newly installed version.

I'm not sure if your question is "how to write the script" or "how to install it when it's done"? So, apologies if I'm telling you what you already know because I wasn't sure where to start. Once it's written and running on your system, packaging will be a later step.

edbarx 03-16-2012 01:44 PM

The patch needs to run immediately after udev populates /dev because it is at that point that the backlight is switched off. I think, your idea of inserting my patch at the end of udev's script is the best option that I may have at the moment.

Thanks.

rigor 03-16-2012 05:21 PM

Hi edbarx,

Sorry but, since "patch" can be used in different ways, and especially since you've said
Quote:

upgrade my linux-image (ie vmlinuz-*)
but didn't appear to specify the exact nature of the workaround, I'm not entirely clear what procedure you expect to follow.

If by "upgrade" you mean replace the vmlinuz-* file, then you would usually need to re-start the kernel in some way, after the "patch", before the patch would have any effect. If that's what you intended, that sounds like a clever idea to automate the patch process. But, I suspect you probably would not want to replace the file containing the running kernel as such, instead you'd want to provide a different kernel file to run, after a re-start. Yet handling that with an init-script, you'd probably want to be very sure that the init-script did the "patch", only once after the first re-start of the kernel, in response to an upgrade to the major version of GNU/Linux. Otherwise you could create a so called "infinite loop" of kernel re-starts.

If instead, you are are talking about changing values in kernel memory for a kernel that's already running, without re-starting the kernel after the changes, you'd need to be very sure that you were changing values that either didn't need to effectively be copied to somewhere else in kernel memory, or hadn't already been copied, and also could be accessed safely at that exact moment.

edbarx 03-21-2012 05:50 PM

For simple commands placing them in /etc/rc.local is enough. This is what I did and it worked.


All times are GMT -5. The time now is 10:48 PM.