View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 5 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Sun Apr 12, 2009 11:53 am 
Offline
Joined: Sun May 30, 2004 11:05 am
Posts: 37
Location: Acton, Ontario, Canada
SEE LAST POST FOR MY SOLUTION (with code)

To all:

We may have a working solution for all those out there using any of the various methods to have their backend(s) go to sleep and wake to record.

I been norking around with this issue for a couple of weeks in an attempt to get MythWeb working remotely.

I noted with great interest that the MythWeb settings page:

http://<hostname>:<port>/mythweb/settings/settings

shows the option for "MythShutdownLock".

Modifying this from '0' to '1' and then saving the settings will lock the backend from shutting down.

On my MythWelcome page on my master backend, it indeed shows myth locked from shutting down with no other intervention.

When I mod the value in the settings page from '1' back to '0' and save again, my backend goes into its timed shutdown, runs its custom mythpreshutdown check, runs 'mythshutdown --check' and behaves normally.

QUESTION: since the settings page is in the default MythWeb setup on R5F27 KnoppMyth, all things being equal, and a secure web connection setup (via SSH tunneling OR SSL web interface -- see wiki for howtos), how HARD would it be to modify the PHP scripting to provide a custom button or hyperlink to lock/unlock the shutdown?

This may be the solution many of us have been seeking.

However, I am (at best) a kludge coder, so any suggestions from those with greater expertise would be gratefully accepted.

I would gladly add this mod myself and post the results in the wiki. Regardless of whether a solution along my thought line proceeds or not, I will use this MythShutdownLock setting from now on while connected by MythWeb.

_________________
Squiff
______________________________________
ECS K7SOM+ (v7.5c)m embedded AMD CPU
512 MB RAM, 120 GB HDD
DVD, FDD
PVR250, Plextor TV-M402U (go7007 method)
R5F27 (ACPI_wake method)
Mythwelcome


Last edited by squiffy on Fri Apr 17, 2009 7:55 pm, edited 1 time in total.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 13, 2009 4:37 am 
Offline
Joined: Sat May 12, 2007 2:41 am
Posts: 51
Location: Southern Germany
Are you sure MythShutdownLock is a 0/1 toggle? It might as well be a counter, so when several things lock the shutdown takes values > 1.

Imagine for example that you start your mythweb session 20 minutes before a scheduled recording is about to begin. After 10 minutes you end your mythweb session and and set MythShutdownLock to zero. What will happen? Will it shutdown, or will it record? I don't know, but I would assume the former is the case...

But that would actually be the preferrable thing to happen: In this case the solution you propose is the correct way to deal with this: In mythweb make a button to increase the MythShutdownLock Counter, and when you are done, simply decrease it by one, instead of setting it to zero.

Not totally safe against incorrect user behaviour, but if you are careful, this should work.

jens


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 13, 2009 3:09 pm 
Offline
Joined: Sun May 30, 2004 11:05 am
Posts: 37
Location: Acton, Ontario, Canada
heilig wrote:
Are you sure MythShutdownLock is a 0/1 toggle? It might as well be a counter, so when several things lock the shutdown takes values > 1.


When I "Lock Shutdown" from the MythWelcom page, it changes to '1' on the MythWeb Settings page.

However, you are quite correct that my simplifying assumption may be false about the 0/1 thing. That is because the usage information for 'mythshutdown' clearly states that if 'mythshutdown --lock' is invoked, running 'mythshutdown --status' should spit back a value of "16".

I will have to try some values on MythWeb Settings page and see if it either rejects them or changes the status like an electrician's Lock-Out/Tag-Out.

heilig wrote:
Imagine for example that you start your mythweb session 20 minutes before a scheduled recording is about to begin. After 10 minutes you end your mythweb session and and set MythShutdownLock to zero. What will happen? Will it shutdown, or will it record? I don't know, but I would assume the former is the case...


Actually, I don't think it would shutdown, since the "mythshutdown --check" should run (as required) by the pre-shutdown sequencing and is supposed to avert a shutdown if recording is occurring.

However, you have raised a doubt. I will check my MythWeb page while a recording is occurring and see what the Settings page says while this is happening. Let you know shortly.

heilig wrote:
But that would actually be the preferrable thing to happen: In this case the solution you propose is the correct way to deal with this: In mythweb make a button to increase the MythShutdownLock Counter, and when you are done, simply decrease it by one, instead of setting it to zero.

Not totally safe against incorrect user behaviour, but if you are careful, this should work.

jens


This is really what I was thinking too. I am really the only one in my household who uses MythWeb, and my spouse could be easily given end-user training for her Blackberry web interface to prevent causing a premature shutdown.

Thanks for the interest...will feed back shortly...stay tuned.

_________________
Squiff
______________________________________
ECS K7SOM+ (v7.5c)m embedded AMD CPU
512 MB RAM, 120 GB HDD
DVD, FDD
PVR250, Plextor TV-M402U (go7007 method)
R5F27 (ACPI_wake method)
Mythwelcome


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 13, 2009 8:50 pm 
Offline
Joined: Sun May 30, 2004 11:05 am
Posts: 37
Location: Acton, Ontario, Canada
heilig wrote:
Are you sure MythShutdownLock is a 0/1 toggle? It might as well be a counter, so when several things lock the shutdown takes values > 1.


squiffy wrote:
When I "Lock Shutdown" from the MythWelcom page, it changes to '1' on the MythWeb Settings page.


I believe I can confirm that the item "MythshutdownLock" is part of the mythconverg database in one of the tables and Mythweb's Settings page is accessing (or writing) values from that table.

As well, doing a little online digging on the Main MythTV site indicates that the values of MythshutdownLock are integers '0' (for unlock) or '1' (for lock).

squiffy wrote:
I will have to try some values on MythWeb Settings page and see if it either rejects them or changes the status like an electrician's Lock-Out/Tag-Out.


Placing other values in the field on MythWeb settings did nothing to the lock status. Changing it to '1' locked the backend. No other value seemed to do anything.

So, I think that someone with some PHP experience could perform a little scripting magic to either:

A) Create a special "lock page" in Mythweb that allows easier lock/unlock of the backend OR;

B) Add a Button (or checkbox or radio buttons) in the file header.php that will show the current status of MythshutdownLock and allow a faster change of status.

I will certainly make a stab at such a change. However, my PHP knowledge is very limited, so if anyone can offer some hints I get the concept, I just need a little coaching to get me through the coding.

_________________
Squiff
______________________________________
ECS K7SOM+ (v7.5c)m embedded AMD CPU
512 MB RAM, 120 GB HDD
DVD, FDD
PVR250, Plextor TV-M402U (go7007 method)
R5F27 (ACPI_wake method)
Mythwelcome


Top
 Profile  
 
PostPosted: Fri Apr 17, 2009 8:23 pm 
Offline
Joined: Sun May 30, 2004 11:05 am
Posts: 37
Location: Acton, Ontario, Canada
To all:

I think I have a working solution with PHP code for KnoppMyth R5F27 users.

My search involved trying to find a convenient way to lock my master backend from going to sleep using MythWelcome with MythShutdown and a custom MythPreshutdown Script. I use an iPhone over wireless to Wake my backend from sleep, then use Safari browser with iPodFeed scripting to see content pseudo-streamed over my WiFi network. I needed a convenient way to avert a shutdown timeout, which the base MythWeb will not prevent. I did NOT want to get into ssh stuff, since with the iPhone keyboard is a royal pain in the petoot.

This is not earth shattering stuff here. Just a recast and tweak of the great work of many others, particularly 'Xris' who authored much of the code I have modded. By doing a little detective work, I have created a modified init.php script for the MythWeb 'settings' module and two new files called 'locker.php'. One resides in the main settings module directory, the other is copied to MythWeb template directories called 'default' and 'compact'

CAVEATS (big time). The scripts created may have unforeseen effects on your system, as I am NOT a PHP coder nor do I claim to have a detailed understanding of all the intricacies of MythTV and its underlying database.

I am monkeying with an integer value in the "settings" datatable in the 'mythconverg' database at the heart of MythTV.

Further, I am the SOLE user of MythWeb in my setup. I cannot foresee all the end-user setups out there and cannot predict how multiple users of MythWeb all connects and using this universally available page will do.

OK -- scare tactics and FUD are over. If you are still interested...here we go...this appears to work quite nicely.

For KnoppMyth R5F27:

1) start up a root terminal session any way you prefer;

2) goto

Code:
root# cd /usr/share/mythtv/mythweb/modules/settings


3) In this folder you will modify the file 'init.php' and append a module so that it will display this link to your lock/unlock routine.

This is the modified file with the new code right near the end

Code:
<?php
/**
 * Initialization routines for the MythWeb settings module
 * MAKE SURE you copy original init.php to init.old first
 * save this file under ./modules/settings/init.php
 * @url         $URL$
 * @date        $Date$
 * @version     $Revision$
 * @author      $Author$
 * @license     GPL
 *
 * @package     MythWeb
 * @subpackage  Settings
 *
/**/

// The settings module is always enabled.
    $Modules['settings'] = array('path'        => 'settings',
                                 'sort'        => 999,
                                 'name'        => t('Settings'),
                                 'description' => t('settings'),
                                 'links'       => array('session'   => t('MythWeb session settings'),
                                                        'mythweb'   => t('MythTV global defaults'),
                                                        'channels'  => t('MythTV channel info'),
                                                        'keys'      => t('MythTV key bindings'),
                                                        'settings'  => t('MythTV settings table'),
                                                        'locker'    => 'MythTV backend locker',  //this is the new code
                                                       ),
                                );


The new code is the 'locker' line that you will add.

RECOMMENDATION: copy your original init.php to init.old (or similar) in case you want to undo this mod later more easily.

4) Now, you will use your favorite editor to create a file called 'locker.php' that will also reside in the '/usr/share/mythtv/mythweb/modules/settings' directory.

Its contents are:

Code:
<?php
/**
 * Configure MythTV Shutdown Lock
 * Save this file to ./modules/settings/locker.php
 * @url         $URL$
 * @date        $Date$
 * @version     $Revision$
 * @author      $Author$
 * @license     GPL
 *
 * @package     MythWeb
 * @subpackage  Settings
 *
/**/

// Specific host?
    isset($_GET['host']) or $_GET['host'] = $_GET['host'];
    if (empty($_GET['host']))
        $_GET['host'] = null;

// Save?
    if ($_POST['set']) {
        foreach ($_POST['locker'] as $value => $data) {
            setting('MythShutdownLock', 'null', $data);
        }
    }

// LOCK ?
    if ($_POST['lock']) {
        setting(MythShutdownLock, null, 1);
    }

// UNLOCK
    if ($_POST['unlock']) {
        setting(MythShutdownLock, null, 0);
    }


// Load all of the known mythtv hosts
    $Hosts = array();
    $sh = $db->query('SELECT DISTINCT hostname FROM settings ORDER BY hostname');
    while (list($host) = $sh->fetch_row()) {
        if (empty($host))
            continue;
        $Hosts[] = $host;
    }
    $sh->finish();

// Load just the MythShutdownLock setting for the requested host
    $Locker = array();
    if (is_null($_GET['host']))
        $sh = $db->query('SELECT value, data
                           FROM settings
                           WHERE hostname IS NULL AND value="MythShutdownLock"
                         ');
    else
        $sh = $db->query('SELECT value, data
                           FROM settings
                           WHERE hostname=? AND value="MythShutdownLock"',
                           $_GET['host']);
    while (list($value, $data) = $sh->fetch_row()) {
        $Locker[$value] = $data;
    }
    $sh->finish();

// Load the class for this page
    require_once tmpl_dir.'locker.php';

// Exit
    exit;


This is essentially a mod to the original 'settings.php' file created for MythWeb.

However, since we need only one setting to change in the settings data table in mythconverg, I hard-coded the writes to the table.

5) Now you will use your favourite editor again to create another file called 'locker.php' but this will be saved in the template folders for the default MythWeb and compact MythWeb.

This 'locker.php' will be save to:

/usr/share/mythtv/mythweb/modules/settings/tmpl/default
AND
/usr/share/mythtv/mythweb/modules/settings/tmpl/compact

The file contents are:

Code:
<?php
/**
 * Configure MythTV MythShutdownLock toggle
 * store as ./modules/settings/tmpl/default/locker.php
 * and to   ./modules/settings/tmpl/compacy/locker.php
 * @url         $URL$
 * @date        $Date$
 * @version     $Revision$
 * @author      $Author$
 * @license     GPL
 *
 * @package     MythWeb
 * @subpackage  Settings
 *
/**/


// Set the desired page title
    $page_title = 'MythWeb - Backend Locker';

// Print the page header
    require 'modules/_shared/tmpl/'.tmpl.'/header.php';

?>

<form class="form" method="post" action="<?php echo root ?>settings/locker?host=<?php echo rawurlencode($_GET['host']) ?>">
<br />
<p align="center">
<?php echo 'Myth Backend Locker' ?>
</p>

<center>
<?php
    foreach ($Locker as $value => $data) {
    switch ($data) {
      case 1:
        echo "Backend is currently LOCKED";
//        $chkLock = "checked";
        break;
      case 0:
        echo "Backend is UNLOCKED";
//        $chkLock = "unchecked";
        break;
    }
}
?>

<br />
<p align="center">
<input type="submit" name="lock" value="LOCK" style="height:3em; width:10em;"> ------------
<input type="submit" name="unlock" value="unlock" style="height:3em; width:10em;">
</p>

</form>
<?php
// Print the page footer
    require 'modules/_shared/tmpl/'.tmpl.'/footer.php';
?>


The buttons are extra large to make them visible on my iPhone. Again, this file is a recast settings table.

If all worked correctly, you will see a new hyperlink on the Settings Page and your locker will allow you to enforce a 'MythShutdownLock' via MythWeb.

User Feedback Please.

Any PHP folks out there who can clean up my mess...thanks in advance.

_________________
Squiff
______________________________________
ECS K7SOM+ (v7.5c)m embedded AMD CPU
512 MB RAM, 120 GB HDD
DVD, FDD
PVR250, Plextor TV-M402U (go7007 method)
R5F27 (ACPI_wake method)
Mythwelcome


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu