-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mythshutdown control #266
Comments
Can you provide more details on what specifically would be required? |
I don't know exactly how shutdown prevention happens in code. Perhaps the backend idle time counter is periodicly zeroed or smth. The shutdown feature is somehow explained here: https://www.mythtv.org/wiki/Mythshutdown I would like MAF to provide me a way to forcefully keep mythbackend turned on. E.g.to have a button with functionality: "keep mythtv turned on"/ "let mythtv automatically shutdown". Otherwise backend shuts down after idle timeout. Sometimes I want to force it being running. |
This process is controlled by the mythtv protocol and registering a front On Thu, Dec 4, 2014, 3:51 PM Ilkka Tengvall notifications@github.com
|
This is a ticket which describes the mythtv problem: https://code.mythtv.org/trac/ticket/12089 |
UPnP works exactly the same way as it does not to use the mythtv protocol. On Thu, Dec 4, 2014, 3:57 PM Ilkka Tengvall notifications@github.com
|
Ah, too bad then... |
mythshutdown --lock increments a variable in the settings table. If you're able to write Note that the following is just an example, it has very little error handling and only HOSTNAME=yourBackendHostNameOrIp
SD_LOCK_COUNT=$(curl --silent \
$HOSTNAME:6544/Myth/GetSetting?Key=MythShutdownLock | \
sed -e "s/^.*<Value>//" -e "s/<\/Value>.*$//")
SD_LOCK_COUNT=$(($SD_LOCK_COUNT+1))
SET_RESULT=$(curl --silent \
--data Key=MythShutdownLock \
--data Value=$SD_LOCK_COUNT \
$HOSTNAME:6544/Myth/PutSetting | \
sed -e "s/^.*<bool>//" -e "s/<\/bool>.*$//")
if [ "$SET_RESULT" != "true" ]; then
echo 'Unable to set the lock.'
exit 1
fi
SD_LOCK_COUNT=$(curl --silent \
$HOSTNAME:6544/Myth/GetSetting?Key=MythShutdownLock | \
sed -e "s/^.*<Value>//" -e "s/<\/Value>.*$//")
echo "Lock counter = $SD_LOCK_COUNT" |
Added PHP version of the above. <!-- Install this on the Master Backend. Save as: shutdownlock.php.
Put it in the same directory as mythweb, for example: /var/www
(NOT under mythweb.) -->
<html>
<header>
<title>Control Shutdown Lock</title>
<?php
$hostname="localhost";
function http_request($method, $endpoint, $rest) {
global $hostname;
$params = array("http" => array(
"method" => $method,
"content" => $rest
));
$context = stream_context_create($params);
$fp = @fopen("http://$hostname:6544/$endpoint", "rb", false, $context);
if (!$fp) {
echo "fopen() failed\n";
throw new Exception("fopen() error: $endpoint, $php_errormsg");
}
$xml_response = @stream_get_contents($fp);
if ($xml_response === false) {
echo("xml_response failed");
throw new Exception("Read Error: $endpoint, $php_errormsg");
}
return $xml_response;
}
function parse_xml_response($xml_response, $pattern) {
$value = "none";
$xml = new XmlReader();
$xml->xml($xml_response);
while($xml->read()) {
if ($xml->nodeType == XMLReader::ELEMENT && $xml->name == $pattern) {
$value = new SimpleXMLElement($xml->readOuterXML());
break;
}
}
return $value;
}
function adjust_lock($increment) {
$xml_response = http_request("GET" ,"Myth/GetSetting",
"Key=MythShutdownLock");
$sd_lock_value = parse_xml_response($xml_response, "Value");
if ($sd_lock_value == "none") {
echo "Error: Unable to get the shutdown lock count.";
return;
}
$sd_lock_value = $sd_lock_value + $increment;
if($sd_lock_value < 0) {
$sd_lock_value = 0;
}
$xml_response = http_request("POST", "Myth/PutSetting",
"Key=MythShutdownLock&Value=$sd_lock_value");
$sd_lock_bool = parse_xml_response($xml_response, "bool");
if ($sd_lock_bool == "true") {
echo "Current value: $sd_lock_value (non 0 blocks shutdown.)";
}
else {
echo "Error: Unable to set the shutdown lock count.";
}
}
?>
</header>
<body>
MythTV Master Backend Shutdown Controler.<br><br>
<?php
echo "<form method='post' action='shutdownlock.php'>";
echo " <input type='submit' name='increment_lock' value='Increment'/>";
echo "</form>";
echo "<form method='post' action='shutdownlock.php'>";
echo " <input type='submit' name='decrement_lock' value='Decrement'/>";
echo "</form>";
if($_POST["increment_lock"]) {
adjust_lock(1);
}
if($_POST["decrement_lock"]) {
adjust_lock(-1);
}
?>
</body>
</html> |
Thanks billmeek for the code sample! I confirm it works, I added some lines to beginning to show the current value always: <?php
$xml_response = http_request("GET" ,"Myth/GetSetting",
"Key=MythShutdownLock");
$sd_lock_value = parse_xml_response($xml_response, "Value");
if ($sd_lock_value == "none") {
echo "Error: Unable to get the shutdown lock count.";
}
echo "current lock counter value: [$sd_lock_value]";
... Do you think this could be added somewhere into mythweb as a feature? I suppose the way ahead would be to wait for a day that someone would patch the API to include such entry for shutdownlock. Then it could be added to feature suggestion list of different clients. It would be great to have that on mythweb, xbmc cmyth plugin, and on andoid client. |
hmmm, I don't know much about java, but I quickly looking at the java API, it has api calls for get/put settings at: But as said, I have no glue if those could be used. |
Hi, Also, it was interesting to note that the mythweb developer closed ALL FYI (and Dan and Sebastien), I wrote a patch for ticket 12089 that adds the |
billmeek, I briefly checked your patch, and comment on it here, as I've unfortunately lost my password to trac. There might be locking problem in error case, since the if (error) statements return without releasing the db lock. Perhaps unlock calls prior returning in error cases? |
@ikke-t, thanks, fixed. I'll add the new version when mythtv.org is back on-line. |
Please add button or menu to control mythshutdown lock.
I often use some dlna player, and it's inconvenient to ssh to mythbackend to do:
mythshutdown --lock or -u
MAF could have a control button for it.
The text was updated successfully, but these errors were encountered: