.../sleep.d script not fully running at resume state
Hi,
I am trying to write a script run at resume from suspend to RAM. I know a bit about scripting as I have other .sh, but that type of scripting I am having a hard time understand and my script does not do all I ask for. My script is located in Code:
/usr/lib/pm-utils/sleep.d Code:
80fancontrol_cd Basically it's to kill 'fancontrol' and 'cairo-dock' at resume state and restart them. Why I need to kill both? Different reasons, they have bugs I have logged and I try to find an automatic workaround in the meantime. Ask me for more details if you want. My script had various versions. Here's the latest: Code:
#!/bin/bash The actual behavior is that both 'fancontrol' and 'cairo-dock' do get killed. But none are restarting. I can't find why and don't know where to troubleshoot. Fancontrol needs to be run as root and cairo-dock as user (frank). I read this to understand more http://sial.org/howto/shell/background/ Apparently I need to dissociate 'fancontrol' from the terminal, cuz it's a deamon. So I tried the following script: Code:
#!/bin/bash It's very easy to start cairo-dock from terminal (fancontrol as well). If I type myself as user the 'nohup' lines it will start fancontrol and get out of terminal and will start cairo-dock and get out of terminal. So why it's not even starting when that script run? I can't figure out where I am messing up. Can anyone help me understand my problem so I can find what's wrong? tnx a lot! |
Quote:
|
Fortunately I am not in a network.
By SUID do you mean Code:
chmod 4755 After doing 'chmod 4755' to the file, I have tried with the semi-columns after the command, but that does not run the command, in fact I put the ; only after the 'cairo-dock' launch command and the 2 'pkill', which are before the 'cairo-dock', did not even run. Code:
#!/bin/bash Then I tried without the ; but still with 'chmod 4755'. It runs just like before, which is killing both processes but not launching cairo-dock. The above script does not even try to start 'fancontrol'. I only try to kill both processes and launch cairo-dock. Once I'll succeed with this, I'll look around for fancontrol. But maybe it should be the other way around, trying fancontrol (which is run under root) first and when it works, trying cairo-dock. Now by removing the frills, do you mean I should only simplify the script like this: Code:
#!/bin/bash tnx |
A further simplification might be:
#!/bin/sh pkill cairo-dock ; pkill fancontrol ; nohup fancontrol > /dev/null 2>&1 & ; nohup cairo-dock -o > /dev/null 2>&1 & ; exit The 'extra' spaces should not matter. The semicolons should. But what do I know, I only dabble a little in shell scripts and try not to wander too far from the basics. |
I can only do one test a day, cuz I suspend once per day, so testing takes a while. loll
It did act a little differently with your suggestion, I thought the ";" only after the commands that where not running. So what it does now is it kills fancontrol and cairo-dock at suspend, probably cuz I don't specify to do it at resume, as the scripts in sleep.d folder are supposed to run at suspend and resume by default, otherwise specified within the script. But at resume it does not run cairo-dock, neither fancontrol. And I have tried them independently from each other. One day I tried launching cairo-dock and the next fancontrol. So now I will incorporate your script within the case of a resume only. Maybe it will work. And I will try launching cairo-dock with a 'sudo -u'. Maybe it's just a matter of finding the right combination of arguments. |
suspend - resume
First, do not clump all the commands under the single 'thaw | resume' thingy.
Second, the 'case/esac' set compares the conditions, ie. suspend OR resume, for commands to run. Third, if you truly wish to tailor your script to your system you will look at the specific usages of 'case/esac' scripting in other scripts. There are subtle, or dramatic, differences in tree naming, shell naming, and other 'proprietary' things among the various flavors of Linux/UNIX but it's almost always safe to use #!/bin/sh as the first line; that's all the 'porting' a flavor should need. It seems to me that almost all the scripts under /etc/rc.d/init.d/ or /etc/init.d, whatever, are prime examples to study for proper usage of the 'case' language as practiced by your 'flavor' fanatics and how to write usage and end conditions for your flavor. Being a 'fanatic' is NOT a career help. |
Yes I see it's a bit more complex than I thought for that type of script, though the requirement behind it is quite easy to understand. Easy requirement != all the time easy scripting. :)
Then I will look at the other scripts in *.d and try to use the same basics, if I go with the case/esac structure. What I don't understand is if I don't clump my commands under the 'thaw|resume' condition, the commands run both when suspending and resuming (which is what they are supposed to do if the case/esac isn't set). Not sure it matters if I can write the script with regards to this, though. I need to read more stuff and perfect my scripting. |
Quote:
hibernate|suspend) ;; thaw|resume) The above statement from your original script completely ignores the hibernate OR suspend condition as a cause for action. It glides right past those conditions and goes to the thaw OR resume condition. Your only actions will be taken when the thaw OR resume condition occurs. In plain English, what your original scripts says: "In the case of hibernate OR suspend) do nothing; In the case of thaw OR resume) perform all the sleep functions AND all the wake-up functions;" A better approach will clump all the sleep functions under the condition of the sleep synonyms; hibernate OR suspend, and clump all the wake-up functions under the wake-up synonyms; thaw OR resume. I leave the particular writing as an exercise for your elucidation; I certainly do not know what your needs really are and I ain't writing your script for you. |
Quote:
I have different setups to try, based on the existing files in that folder for my distro. I guess one of them will help me figure out the right one for my script. tnx |
All times are GMT -5. The time now is 02:13 AM. |