On Wednesday 17 October 2012 07:36 PM, Jasmine Hassan wrote: > Sorry I wasn't clear (and for the typo). Rephrase: > 1. start laptop-mode > 2. nano /etc/laptop-mode/laptop-mode.conf > and change: > ENABLE_LAPTOP_MODE_TOOLS=1 > to: > ENABLE_LAPTOP_MODE_TOOLS=0 > > Now, although laptop-mode is enabled, the init script doesn't tell the > actual status, when invoking `service laptop-mode status`.
The problem seemed to be caused because we were exiting if LMT was disabled in the config file. Attached patch should help improve your use case. But I would like to change the way LMT invokes. Currently it is a hodge podge of /var/run/laptop-mode-tools/enabled and ENABLE_LMT settings. LMT now is events based. So as soon as the kernel and the basic system is up, it gets invoked. It needs to be checked how LMT behaves when invoked before the initscript. In the init script, it is invoked with "init auto" argument. Also the /var/run/laptop-mode-tools/enabled file is created there. Where as when invoked through udev, we pass it the "auto" argument only. There are many problems here: * When invoked through init scripts, it touched the "enabled" file, then called LMT, realized that ENABLE_LMT was set to 0 and it exited. But it did not clean the "enabled" file. For that, I proposed the change in one of the previous emails. * When invoked through udev, we do not care or create the "enabled" file. With it, when the ENABLE_LMT is set to 0, we get rrs@champaran:~$ sudo /usr/sbin/laptop_mode auto [sudo] password for rrs: Warning: Configuration file /etc/laptop-mode/conf.d/board-specific/*.conf is not readable, skipping. laptop-mode-tools is disabled in config file. Exiting With ENABLE_LMT=1, we get rrs@champaran:~$ sudo /usr/sbin/laptop_mode auto Warning: Configuration file /etc/laptop-mode/conf.d/board-specific/*.conf is not readable, skipping. Laptop mode enabled, active [unchanged] With "enabled" file removed, it shows: rrs@champaran:~$ sudo rm /var/run/laptop-mode-tools/enabled rrs@champaran:~$ sudo /usr/sbin/laptop_mode auto Warning: Configuration file /etc/laptop-mode/conf.d/board-specific/*.conf is not readable, skipping. Laptop mode disabled, not active [unchanged] So it just disabled LMT because it was not "enabled". And if "enabled" is set again, things go right. rrs@champaran:~$ sudo touch /var/run/laptop-mode-tools/enabled rrs@champaran:~$ sudo /usr/sbin/laptop_mode auto Warning: Configuration file /etc/laptop-mode/conf.d/board-specific/*.conf is not readable, skipping. Laptop mode enabled, active There are 2 items to fix. * Invocation * Status If you have time, you can review the patch and do some tests. Let me know. * * -- Ritesh Raj Sarraf RESEARCHUT - http://www.researchut.com "Necessity is the mother of invention."
diff --git a/usr/sbin/laptop_mode b/usr/sbin/laptop_mode index 4628bc8..c60074a 100755 --- a/usr/sbin/laptop_mode +++ b/usr/sbin/laptop_mode @@ -251,11 +251,6 @@ lmt_load_config () exit 1 fi - if [ x$ENABLE_LAPTOP_MODE_TOOLS = x0 ]; then - log "MSG" "laptop-mode-tools is disabled in config file. Exiting" - exit 0; - fi - # Add a simple bash debug mode switch if [ "$DEBUG" -eq 1 ]; then set -vx; @@ -630,6 +625,10 @@ lmt_main_function () mkdir -p /var/run/laptop-mode-tools + if [ x$ENABLE_LAPTOP_MODE_TOOLS = x1 ]; then + touch /var/run/laptop-mode-tools/enabled + fi + # Used to display laptop mode state later on. This is the enabled/disabled # state for laptop mode processing, it tells us nothing about whether laptop # mode is actually _active_. @@ -683,16 +682,22 @@ lmt_main_function () # If the init script has not been run or has been run with the "stop" # argument, then we should never start laptop mode. - if [ ! -f /var/run/laptop-mode-tools/enabled ] ; then + if [ ! -f /var/run/laptop-mode-tools/enabled -o x$INITSCRIPT_STOP = x1 ] ; then log "VERBOSE" "Laptop mode disabled because /var/run/laptop-mode-tools/enabled is missing." STATE=disabled fi - if [ "$ACTIVATE" -eq 1 -a -f /etc/default/laptop-mode ] ; then - . /etc/default/laptop-mode - if ! ( echo "$ENABLE_LAPTOP_MODE" |grep y ) ; then + if [ "$ACTIVATE" -eq 1 ]; then + if [ -f /etc/default/laptop-mode ] ; then + . /etc/default/laptop-mode + if ! ( echo "$ENABLE_LAPTOP_MODE" |grep y ) ; then log "VERBOSE" "Not starting laptop mode because it is disabled in /etc/default/laptop-mode." STATE=disabled + fi + fi + if [ x$ENABLE_LAPTOP_MODE_TOOLS = x0 ]; then + log "VERBOSE" "Not starting laptop mode because it is disabled in /etc/laptop-mode/laptop-mode.conf" + STATE=disabled fi fi
signature.asc
Description: OpenPGP digital signature