oztoppy Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment   Page 1 of 4      1   2   3   4   Next
keith_leitch

Senior Member
Registered:
Posts: 525
Reply with quote  #1 
I am using TMSServer to run my own custom scripts to save TAP space, as DMC suggested around this time last year. Some of those scripts I would like to start and stop on demand. 

1) Is there a back-door to access the TMSServer control screen without using TMSCommander?

2) Can I customise the list of servers on the control screen, so that I can run "start" and "stop" scripts, passing parameters in the same manner that the standard scripts work?
0
DeltaMikeCharlie

Mostly Harmless
Registered:
Posts: 235
Reply with quote  #2 
Quote:
Originally Posted by keith_leitch
1) Is there a back-door to access the TMSServer control screen without using TMSCommander?

There is a backdoor for TMSServer:  Select the PVR Menu and then enter "Settings".  Press the "File List" button and the TMSServer menu will be diaplayed.

For TMSClient, use the same process but with the "Sat" button.

If you want these changed, just ask.

Quote:
Originally Posted by keith_leitch
2) Can I customise the list of servers on the control screen, so that I can run "start" and "stop" scripts, passing parameters in the same manner that the standard scripts work?

By "list of servers" I assume that you are referring to the list of the services that TMSServer supports.  By default, these are: RPC to port mapper, TELNET server,TELNET server (BusyBox), NFS Server and FTP server (Port 88).

For each of these services, there is a control file.  Let's examine NFS as an example:

The control file for NFS is "040-unfsd.control", this is simply a script that TMSServer executes.  The script returns a string to TMSServer with a status response.  When executed with no argument, the current status is returned:

The second last active line of the script looks like this:

echo $STATUS,NFS@$EXPRT,NFS Server

This is simply the status message that TMSServer reads in once the script is complete.  The status message is in the format [return code],[protocol advertisement],[Description].

You just need to change the [Description] above.

Code:
sh 040-unfsd.control
1,NFS@/mnt/hd/DataFiles@/mnt/hd/MediaFiles@/mnt/hd/PhotoFiles@/mnt/hd/MP3Files@/mnt/hd/ProgramFiles@,NFS Server

sh 040-unfsd.control start
2,NFS@/mnt/hd/DataFiles@/mnt/hd/MediaFiles@/mnt/hd/PhotoFiles@/mnt/hd/MP3Files@/mnt/hd/ProgramFiles@,NFS Server

sh 040-unfsd.control stop
0,NFS@/mnt/hd/DataFiles@/mnt/hd/MediaFiles@/mnt/hd/PhotoFiles@/mnt/hd/MP3Files@/mnt/hd/ProgramFiles@,NFS Server

You can also change the order in which services appear on the list and are executed by renumbering the control files.

The "control" files are used to start/top services automatically at startup or manually whenever.  The presence of a "bypass" prevents automatic startup of a service.  The "shutdown" scripts are run in alphabetical order when TMSServer is given a shutdown command from the user or the PVR firmware.

Let me know if you need any more information.
0
keith_leitch

Senior Member
Registered:
Posts: 525
Reply with quote  #3 
Thanks. As an experiment, I tried to enter a line like that in my own control file. I called it 090-ExternalDisks.control . It is currently setting a mountpoint under Datafiles for any external disks that are connected. It works fine when TMSServer starts and, it seems, whenever I enter the menu.

I put the following line second-last in my script:

echo "$STATUS,EXTERNALDISKS,External Disks"

CORRECTION: I didn't have the quotation marks before, so now it is working. Thanks!

A related question: Is there a programmatic way to trigger the scripts without starting another instance of TMSServer? I would like the mounting to be triggered by a disk being connected (I guess I will need to find the event for that, too).

The back-door to the menus is good, but the only problem is that I can't program a reliable TMSmacro, because the native menu does not always default to the same submenu: sometimes it starts on "Recording," other times on "Settings," etc. I am looking for a way to hot-key this.

It is good to know what the .bypass file is for.
0
keith_leitch

Senior Member
Registered:
Posts: 525
Reply with quote  #4 
A bigger issue: To diagnose a problem, I just executed a shutdown -h through Telnet. The Telnet window closed, but I had an unresponsive PVR still playing the broadcast station, Checking HDD on restart, etc. This confirmed a suspicion.

However, something more is wrong, now. I am struggling to run utelnetd through TMSServer (though the Busybox version works fine, and the other's executable is still in the directory). Pressing Play produces no result. Could this be related?


0
DeltaMikeCharlie

Mostly Harmless
Registered:
Posts: 235
Reply with quote  #5 
Both TELNET services are mutually exclusive.  Have you tried disabling one before enabling the other?
0
keith_leitch

Senior Member
Registered:
Posts: 525
Reply with quote  #6 
Yeah, always. I actually think it's unrelated to the shutdown; earlier, when I was modifying my own script, I accidentally ran it once with the Telnet exit line at the end. I'm thinking the duplicate line might have done something.

It doesn't really matter, as long as the other one is working. It's just a mystery to solve.


0
keith_leitch

Senior Member
Registered:
Posts: 525
Reply with quote  #7 
Oddly, I now can't turn it off. I'm also getting the full HDD check on every boot, so I think I've really screwed something up.
0
DeltaMikeCharlie

Mostly Harmless
Registered:
Posts: 235
Reply with quote  #8 
Quote:
Originally Posted by keith_leitch
A related question: Is there a programmatic way to trigger the scripts without starting another instance of TMSServer?

There is currently no way to for TMSServer to accept commands from other TAPs to execute scripts.  As you would have to write a TAP in C anyway, you could just call the scripts directly from your TAP and achieve the same result.

0
keith_leitch

Senior Member
Registered:
Posts: 525
Reply with quote  #9 
Oh, yes, good point: but I was looking for a quick way to launch them all using the UI. However, I think I've worked out that just opening the TMSServer menu, even using the backdoor, does this for those without a .bypass file.

The matter discussed elsewhere was resolved by using a power-switch code through Webcontrol (a question about that on another thread).

It's all coming together. Thanks to your help, I've got a server script that allows me to safely switch one Toppy on and off from another via TMSServer; essential when sharing files between them.



0
DeltaMikeCharlie

Mostly Harmless
Registered:
Posts: 235
Reply with quote  #10 
Quote:
Originally Posted by keith_leitch
I would like the mounting to be triggered by a disk being connected (I guess I will need to find the event for that, too).

Have you tried TMSMount?  I'm not sure if it is a once-off or if it polls.

Here is a rough idea for a script:

With auto-mounting USB devices, you could cheat.

080-USBStart.sh
Code:
sh usblooper.sh&
send return code
usblooper.sh
Code:
do loop
if (USB drives present)
    for each USB drive
        if USB drive not mounted to DataFiles
            mount USB drive to DataFiles
        end if
    end for

    check for removals

else

    check for removals

end if

sleep(10)

end loop

Your shutdown script can just kill usblooper.sh and then delete any mounts.

You can find USB drives by interrogating /proc/mounts or even /proc/bus/usb/devices.  Listing /mnt/hd will also do the trick once the PVR has mounted the device.
0
keith_leitch

Senior Member
Registered:
Posts: 525
Reply with quote  #11 
Thanks for the algo suggestion. I was thinking of doing some polling, but was worried about resource usage. Having said that, I guess a directory monitor must poll, too, at some level.

I'm also concerned about multiple instances of the polling script gumming up resources as TMSServer launches them. I'm thinking that the return-codes could be used to manage that, or maybe something like this: 

http://www.linuxquestions.org/questions/programming-9/preventing-multiple-instances-of-a-shell-script-from-running-concurrently-499750/


My current script is looking at /mnt/hd; do you think there is some advantage in polling the other directories instead? (The /usb directory may not include eSata devices.)

While we're on the subject: I can't seem to find a way to extract a disk's volume label.

Yes, TMSMount is an option, but I am trying to save TAP space.
0
keith_leitch

Senior Member
Registered:
Posts: 525
Reply with quote  #12 
When a script's return code is set to 1 ("started,") does that prevent TMSServer from running it again, even without a .bypass file?
0
DeltaMikeCharlie

Mostly Harmless
Registered:
Posts: 235
Reply with quote  #13 
The original use for TMSServer was to start Linux services like telnet and NFS and broadcast the presence of those services to other Topfield PVRs running TMSClient.  TMSClient would then try to attach to those services if appropriate.

So, the "status" reflects the overall status of the service, not the status of the most recent execution of the script.

0 = Service not running
1 = Service running
2 = Service already running (only happens on a "start" request)

In answer to your question, if you try to start a service that is already running "1", you should get a "2" in response.  From memory, '.bypass' files are only read at startup.  You can manually start a bypassed service.
0
keith_leitch

Senior Member
Registered:
Posts: 525
Reply with quote  #14 
DMC, you mentioned that I can configure the activation keys to shortcut to the menus. How do I do this?

I've noticed an interesting side-effect of shortcutting to the menus. Once I've loaded them, I can switch back and forth between the TMSServer menu and the TMSClient menu, using each respective hot-key. However, once I do that, the TAP menus continue to intercept their keys even after I exit back to playback or Live TV mode. For example, if I press:

Menu/Settings/FileList (to Enter the TMSServer menu)
Exit to Live TV (Blue behaves normally)

Menu/Settings/Sat (to Enter the TMSClient menu)
Exit to Live TV (Blue behaves normally)

...but...

Menu/Settings/FileList (to Enter the TMSServer menu)
Sat (to Enter the TMSClient menu)
Exit to Live TV

...then...

(Blue loads TMSClient settings)
(Yellow controls current client, etc.)

There is no such effect if I open one menu, exit completely, then open the other. There is also no such effect if I enter through TMSCommander.

I think this is because the TAP menus don't change state. In other words, when I backdoor to the TMSServer menu, it thinks it is still in the STATE_Menu, with the Settings loaded. 

I'm not suggesting you do anything to correct this; it takes quite a convoluted sequence to make it happen. Just noting it for posterity.


0
DeltaMikeCharlie

Mostly Harmless
Registered:
Posts: 235
Reply with quote  #15 
Quote:
Originally Posted by keith_leitch
DMC, you mentioned that I can configure the activation keys to shortcut to the menus. How do I do this?

I need to change the source and recompile the TAP.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.