PDA

View Full Version : How do I create a plugin?



nezzeo
07-11-10, 23:46
Ok, so I've got a bunch of linux commands that run at a telnet prompt on the vu box. How do i go about converting this into a plugin so I press a button and have it execute?

nezzeo
08-11-10, 08:49
Sorry for the cross post, I originally posted this in general discussion, but figuered maybe it'd get lost/missed in there and this is probably the better section anyhow.

Anyway, I've got a bunch of linux commands that run at a telnet prompt on the vu box. How do i go about converting this into a plugin so I press a button and have it execute?
Or even have it execute on launch/shutdown

nezzeo
08-11-10, 09:46
if its just some straight linux commands, could I put them at the end of the /etc/rc.d/init.d/smartd file?

pooface
08-11-10, 09:55
Moved in to correct location for you...

As for creating a plugin, you will need to learn python. Have a look at some of the normal plugins, for example the webinfo plugin. You will then need to get the plugin to natively run the commands...

[Edit]
OK, just noticed the cross-posting, so have merged the threads...

nezzeo
08-11-10, 12:13
where are these stored on the box?

pooface
08-11-10, 12:17
where are these stored on the box?

I think, but typing from memory, so not 100% sure it's correct:

/usr/lib/enigma2/python/Plugins

nezzeo
08-11-10, 12:23
ahh ok I see them in /usr/lib/enigma2/python/
I think learning python for what I want to accomplish might be a bit overkill. If I just wanted to run a couple of linux commands on boot, could I just add them to the smartd ?

nezzeo
08-11-10, 15:32
Hmmmm... ok so I've managed to create a .sh script to run the commands, and it executes on bootup.
My "hello world" style thing of "mkdir /tmp/test" works
but the moment I try to do a "cd /etc" it fails, presumably on permissions because it can do "cd /tmp" without a problem. Any ideas how to resolve this?

pooface
08-11-10, 16:02
how about putting your script file in /etc/init.d, chmod it to 755. Then, in telnet, run the following command:


ln -s /etc/init.d/myscriptfile.sh /etc/rc3.d/S99myscript

Then, restart. Should (I think) make it run on startup...

nezzeo
08-11-10, 17:44
Here's my script:



#!/bin/sh
#DESCRIPTION=test script

#mkdir /tmp/test
#cd /tmp/test

cd /etc/enigma2
mkdir /etc/enigma2/test


and when I test run it from telnet I get:



root@vuduo /etc/init.d # sh testscript.sh
: not foundh: line 3:
: not foundh: line 6:
testscript.sh: cd: line 7: can't cd to /etc/enigma2
: not foundh: line 9:
: not foundh: line 12:


yet the makedir command worked because a directory is created?

nezzeo
08-11-10, 20:51
Ah! found my problem, when viewing script in vi on the box, I noticed every line had a ^M (probably windows char return or something)
Sorted and working, thanks for your help :)

When you do a scan, where is the services file stored? Is it just the 1 file or it it multiple?

FYI What I'm doing is forcing the box pull a list of bouquets from some personal webspace and then copy it to /etc/enigma2

nezzeo
08-11-10, 22:26
Ok so got that working, only prob now is that once booted it doesnt go to the defautl channel that it was on before it shutdown. I know there's a plugin for auto-channel, but I dont want it to ALWAYS be the same one. Is there a command I can run in linux to force the zap to the last known chan?

My script is set as S90, so its last in the list of executed before S99rmnologin gets hit, would it help if I put it earlier in the list? say S15 or something?

nezzeo
09-11-10, 17:50
Getting there, getting there. I'm taking a slightly different approach now - I'm now trying to do a "Restart Enigma" and have found this:



Dreamset v2.32

Fixed: import/compare at west services
Fixed: Neutrino HD (Coolstream, etc), Reload settings
Fixed: copy/paste HD services
Added: Change name/provider of multiple selected services
Added: Pre-Telnet and post-Telnet commands, now you can restart enigma2 settings with sequence "init 4; sleep 5", "write files", "init 3".
Added: Setup firmware profiles added "Enigma2 ver 4 (HTTP reload)" and "Enigma2 ver 4 (Telnet reload)"


the init 4... bit works, except the write returns "-sh: write: not found" - any ideas anyone?

silverfox0786
09-11-10, 18:20
i dunno if this will work as im pants with this sort of stuff but maybe try this

#!/bin/sh
#DESCRIPTION=test script

#mkdir /var/tmp/test
#cd /var/tmp/test

cd /var/etc/enigma2
mkdir /var/etc/enigma2/test

thats added the var

ok igonre this post i was wrong

nezzeo
09-11-10, 20:02
i dunno if this will work as im pants with this sort of stuff but maybe try this

#!/bin/sh
#DESCRIPTION=test script

#mkdir /var/tmp/test
#cd /var/tmp/test

cd /var/etc/enigma2
mkdir /var/etc/enigma2/test

thats added the var

ok igonre this post i was wrong

I got past this in the end, problem was my script had some funky ^M chars on the end of each line.

I've finished my script, except for any minor tweaks along the way.
The script now has evolved into a button thats listed under the plugins. When clicked it downloads my latest bouquets/services from some personal webspace, replaces the current ones, tidies up after itself and reboots the box for the changes to take effect (ideally I'd like it so that it just restarts Enigma instead) but no luck with that so far.

The reason for this script? I have a couple of friends with boxes, completely non-technical that I dont fancy visiting only to ftp over my latest files every time sky decide to move a chan or 2. Instead they click a button and job done! :)

pooface
09-11-10, 21:30
The script now has evolved into a button thats listed under the plugins. When clicked it downloads my latest bouquets/services from some personal webspace, replaces the current ones, tidies up after itself and reboots the box for the changes to take effect (ideally I'd like it so that it just restarts Enigma instead) but no luck with that so far.

Congrats in to getting the script finished :)

As for getting it to just restart enigma not the whole box, issue the following command:


killall -9 enigma2

You might get occurrences where the sound does not come with the picture, but if you just change channel, then it will come back...

hth :)

andyblac
14-11-10, 00:49
I got past this in the end, problem was my script had some funky ^M chars on the end of each line.

I've finished my script, except for any minor tweaks along the way.
The script now has evolved into a button thats listed under the plugins. When clicked it downloads my latest bouquets/services from some personal webspace, replaces the current ones, tidies up after itself and reboots the box for the changes to take effect (ideally I'd like it so that it just restarts Enigma instead) but no luck with that so far.

The reason for this script? I have a couple of friends with boxes, completely non-technical that I dont fancy visiting only to ftp over my latest files every time sky decide to move a chan or 2. Instead they click a button and job done! :)

is it a enigma2 plugin ?, if so execute this command,

place this in the top of the plugin

from Screens.MessageBox import MessageBox
place at the end of you current def:

message = 'GUI needs a restart to apply the changes !!!\nDo you want to restart GUI now ?'
ybox = self.session.openWithCallback(self.restBox, MessageBox, message, MessageBox.TYPE_YESNO)
ybox.setTitle('Restart box.')

def restBox(self, answer):
if answer is True:
self.session.open(TryQuitMainloop, 3)
else:
self.close()
it will poup a message box asking do you want to restart gui