Hi all,
I'm playing now with autoshutdown script (the one that is specified with -s switch) and have a question. When power button is pressed, VDR calls the script, but lets say the script decided not to shutdown the PC (other background work is done). I see that VDR shows a countdown of 5 minutes saying that it will shutdown soon.
What are the common ways to cancel that? I thought about sending a "back" button using SVDRP. Is there any other methods? When VDR will try to shutdown next? After user idle timeout?
Thanks. Alex.
On 06.02.2009 13:49, Alex Betis wrote:
I'm playing now with autoshutdown script (the one that is specified with -s switch) and have a question. When power button is pressed, VDR calls the script, but lets say the script decided not to shutdown the PC (other background work is done). I see that VDR shows a countdown of 5 minutes saying that it will shutdown soon.
VDR does not know whether the shutdown script initiated the shutdown or decided to ignore it, so it simply sets the SHUTDOWNRETRY time (6 minutes) until next shutdown attempt. The 5-minute countdown will automatically start after the first minute.
What are the common ways to cancel that? I thought about sending a "back" button using SVDRP. Is there any other methods?
There is no official way to announce background activity from outside of VDR. Sending a keystroke would work, but probably shifts shutdown several hours into the future. Sending a poweroff when done is also a bad idea, as an user might be using VDR by now.
The easiest way is to just assume that no one sees the countdowns, and keep trying shutdown until it succeeds. Any user activity will make the countdown disappear anyway.
Plugins have more control over shutdown, they can report their activity and can even announce future activity, leaving VDR the decision to shut down until then or not.
Cheers,
Udo
On Saturday 07 February 2009, Udo Richter wrote:
On 06.02.2009 13:49, Alex Betis wrote:
I'm playing now with autoshutdown script (the one that is specified with -s switch) and have a question. When power button is pressed, VDR calls the script, but lets say the script decided not to shutdown the PC (other background work is done). I see that VDR shows a countdown of 5 minutes saying that it will shutdown soon.
VDR does not know whether the shutdown script initiated the shutdown or decided to ignore it,
I suppose it would be quite easy to implement that and maybe some other scenarios as well using shutdown script exit statuses. For example exit status 0 = shutdown successfully initiated (already in current VDR), 10 = shutdown ignored, 11 = something else, 12 = something else, anything else = an unexpected error occurred.
On Saturday 07 February 2009, Ville Skyttä wrote:
On Saturday 07 February 2009, Udo Richter wrote:
On 06.02.2009 13:49, Alex Betis wrote:
I'm playing now with autoshutdown script (the one that is specified with -s switch) and have a question. When power button is pressed, VDR calls the script, but lets say the script decided not to shutdown the PC (other background work is done). I see that VDR shows a countdown of 5 minutes saying that it will shutdown soon.
VDR does not know whether the shutdown script initiated the shutdown or decided to ignore it,
I suppose it would be quite easy to implement that and maybe some other scenarios as well using shutdown script exit statuses. For example exit status 0 = shutdown successfully initiated (already in current VDR), 10 = shutdown ignored, 11 = something else, 12 = something else, anything else = an unexpected error occurred.
...and based on some criteria, stdout and/or stderr from the script could be displayed on the OSD.
On 07.02.2009 11:26, Ville Skyttä wrote:
VDR does not know whether the shutdown script initiated the shutdown or decided to ignore it,
I suppose it would be quite easy to implement that and maybe some other scenarios as well using shutdown script exit statuses. For example exit status 0 = shutdown successfully initiated (already in current VDR), 10 = shutdown ignored, 11 = something else, 12 = something else, anything else = an unexpected error occurred.
Unfortunately it's not that easy. Currently, VDR backgrounds the call to the shutdown script, and detaches the shutdown script from the VDR process. Only because of that, the script can 'survive' the kill of VDR, and only because of that the script can display messages via SVDRP.
However, this means that the error level return of the script is unknown to VDR, and is (and was) always ignored. Some shutdown scripts do set error levels, but there's no common definition about the meaning of error levels. Defining error levels for the shutdown script would thereby be potentially incompatible to existing scripts.
Another solution to this would be an external activity handler that is controlled via SVDRP commands, and that provides activity control comparable to plugins for one external instance - the shutdown script. This could either be done by a plugin or a VDR patch.
Cheers,
Udo
On Saturday 07 February 2009, Udo Richter wrote:
On 07.02.2009 11:26, Ville Skyttä wrote:
VDR does not know whether the shutdown script initiated the shutdown or decided to ignore it,
I suppose it would be quite easy to implement that and maybe some other scenarios as well using shutdown script exit statuses. For example exit status 0 = shutdown successfully initiated (already in current VDR), 10 = shutdown ignored, 11 = something else, 12 = something else, anything else = an unexpected error occurred.
Unfortunately it's not that easy. Currently, VDR backgrounds the call to the shutdown script, and detaches the shutdown script from the VDR process. Only because of that, the script can 'survive' the kill of VDR,
Why is that even necessary? Shutdown scripts could selectively background+detach things that need to survive killing of VDR and the script themselves, if any.
and only because of that the script can display messages via SVDRP.
Hmm, why wouldn't a non-background, non-detached script called by VDR be able to do that?
Some shutdown scripts do set error levels, but there's no common definition about the meaning of error levels.
Right, my post was about mentioning a possibility to add such common definitions if found feasible.
Defining error levels for the shutdown script would thereby be potentially incompatible to existing scripts.
Sure. Authors of such scripts get to keep both pieces if their scripts break due to use of undocumented features ;). I suppose changing the shutdown script not to run background+detached would probably be a source of more incompatibilities though, and ones that script authors would not be responsible for.
On 08.02.2009 10:19, Ville Skyttä wrote:
On Saturday 07 February 2009, Udo Richter wrote:
Unfortunately it's not that easy. Currently, VDR backgrounds the call to the shutdown script, and detaches the shutdown script from the VDR process. Only because of that, the script can 'survive' the kill of VDR,
Why is that even necessary? Shutdown scripts could selectively background+detach things that need to survive killing of VDR and the script themselves, if any.
Detaching as a script isn't that easy, the reason for these ugly echo "..." | at now workarounds.
and only because of that the script can display messages via SVDRP.
Hmm, why wouldn't a non-background, non-detached script called by VDR be able to do that?
The main VDR thread would have to wait for the return, and SVDRP won't be handled until then. SVDRP connections from the script would timeout. You can see that if you use SVDRP commands from commands.conf without explicitly backgrounding.
On the error level return, thats also not very practicable for VDR. For VDR the question isn't whether we do shutdown or not. Either there will be a kill signal coming, or there won't. The question for VDR is: If we don't shut down, when should VDR check again, or how does VDR know that the background job is done? An error level return is quite limited here.
Cheers,
Udo
On Sunday 08 February 2009, Udo Richter wrote:
On 08.02.2009 10:19, Ville Skyttä wrote:
On Saturday 07 February 2009, Udo Richter wrote:
Unfortunately it's not that easy. Currently, VDR backgrounds the call to the shutdown script, and detaches the shutdown script from the VDR process. Only because of that, the script can 'survive' the kill of VDR,
Why is that even necessary? Shutdown scripts could selectively background+detach things that need to survive killing of VDR and the script themselves, if any.
Detaching as a script isn't that easy, the reason for these ugly echo "..." | at now workarounds.
There are other alternatives to choose from if one for some reason can't stomach the "at" approach.
and only because of that the script can display messages via SVDRP.
Hmm, why wouldn't a non-background, non-detached script called by VDR be able to do that?
The main VDR thread would have to wait for the return, and SVDRP won't be handled until then. SVDRP connections from the script would timeout. You can see that if you use SVDRP commands from commands.conf without explicitly backgrounding.
That sounds like a bug to me, irrespective of this discussion.
The question for VDR is: If we don't shut down, when should VDR check again, or how does VDR know that the background job is done?
Why would VDR check or care in the first place?
An error level return is quite limited here.
Sure, but quite a bit better than what's currently sanely doable.
On Sat, Feb 7, 2009 at 12:44 AM, Udo Richter udo_richter@gmx.de wrote:
On 06.02.2009 13:49, Alex Betis wrote:
I'm playing now with autoshutdown script (the one that is specified with -s switch) and have a question. When power button is pressed, VDR calls the script, but lets say the script decided not to shutdown the PC (other background work is done). I see that VDR shows a countdown of 5 minutes saying that it will shutdown soon.
VDR does not know whether the shutdown script initiated the shutdown or decided to ignore it, so it simply sets the SHUTDOWNRETRY time (6 minutes) until next shutdown attempt. The 5-minute countdown will automatically start after the first minute.
What are the common ways to cancel that? I thought about sending a "back" button using SVDRP. Is there any other methods?
There is no official way to announce background activity from outside of VDR. Sending a keystroke would work, but probably shifts shutdown several hours into the future. Sending a poweroff when done is also a bad idea, as an user might be using VDR by now.
The easiest way is to just assume that no one sees the countdowns, and keep trying shutdown until it succeeds. Any user activity will make the countdown disappear anyway.
Ok, got the idea. I thought VDR will shutdown itself after that counter, something that is not really wanted. After trying it, I see that it just counts down and call the script again. I saw somewhere in the manual also that it leaves the control to the script (to kill it) and do not exit by itself.
Thanks.
Plugins have more control over shutdown, they can report their activity and can even announce future activity, leaving VDR the decision to shut down until then or not.
Cheers,
Udo
vdr mailing list vdr@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr