Page 1 of 25 12345611 ... LastLast
Results 1 to 20 of 484
  1. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #1  
    I've created a webos app. The UI is just the way I want it. The only thing left is to run a shell script, that I have also created and confirmed works. And to do so from a button in the webos app.

    Is there a way in javascript or html to launch the shell script? The open method of the appMgr only seems to work with registered apps and mime types which won't work for shell scripts.

    Am I going about this all the wrong way?

    I need ideas people!!!

    hehehe!

    Update: The culmination of work on my first app is located in the attachment below....
    Attached Files Attached Files
    Last edited by DrewPre; 04/30/2010 at 05:41 AM.
  2. ird
    ird is offline
    ird's Avatar
    Posts
    156 Posts
    Global Posts
    167 Global Posts
    #2  
    I'm guessing since Preware uses scripts to install certain parts of apps, patches, etc. That the package manager service has some way to execute them.
  3. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #3  
    Yea, I thought so too, but I guess I needed someone to translate/interpret the assistants files for me. There isn't exactly any tutorials for them.

    Reading those files were like reading greek.
  4. #4  
    A mechanism that allowed a webOS app to run any shell command it wanted to would be a HUGE security hole.
    You need to write a service which does exactly and only what you need it to do, and carefully review it so that it doesn't open up any security vulnerabilities.
    See git.webos-internals.org for example services.

    -- Rod
    WebOS Internals and Preware Founder and Developer
    You may wish to donate by Paypal to donations @ webos-internals.org if you find our work useful.
    All donations go back into development.
    www.webos-internals.org twitter.com/webosinternals facebook.com/webosinternals
  5. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #5  
    yea, I took a look at some of the src code for a few of thoses services....it's way above my head. How would one get started writing a service? What are the pre-reqs for learning that kinda stuff?
  6. #6  
    Quote Originally Posted by DrewPre View Post
    yea, I took a look at some of the src code for a few of thoses services....it's way above my head. How would one get started writing a service? What are the pre-reqs for learning that kinda stuff?
    At the moment, you need to know Java.

    In the future, knowing C will be enough.

    Knowing Makefiles will be an advantage for either.

    -- Rod
    WebOS Internals and Preware Founder and Developer
    You may wish to donate by Paypal to donations @ webos-internals.org if you find our work useful.
    All donations go back into development.
    www.webos-internals.org twitter.com/webosinternals facebook.com/webosinternals
  7. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #7  
    I don't know C or Make files...

    I don't know JAVA either... but I took the time to search and teach myself just enough to do this.....

    I also went in a different direction and created this app for the Palm Pre.

    I created these two apps to have two options to perform the same tasks....So I am not completely clueless when it comes to coding.


    I am not asking anyone to spoon feed me but point me in the right direction, please.
  8. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #8  
    Okay maybe I AM asking for someone to spoon feed me. It would be nice if you could put a bib on me and burp me when you're done!!

    I have the time and motivation right now and I want to learn this stuff.
  9. #9  
    Quote Originally Posted by DrewPre View Post
    I don't know C or Make files...

    I don't know JAVA either... but I took the time to search and teach myself just enough to do this.....

    I also went in a different direction and created this app for the Palm Pre.

    I created these two apps to have two options to perform the same tasks....So I am not completely clueless when it comes to coding.


    I am not asking anyone to spoon feed me but point me in the right direction, please.
    git.webos-internals.org Git - services/accelservice.git/blob - AccelService.java and git.webos-internals.org Git - services/optloopservice.git/blob - OptLoopService.java are the simplest Java services there are at the moment.

    What exactly do you need the service to do?

    -- Rod
    WebOS Internals and Preware Founder and Developer
    You may wish to donate by Paypal to donations @ webos-internals.org if you find our work useful.
    All donations go back into development.
    www.webos-internals.org twitter.com/webosinternals facebook.com/webosinternals
  10. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #10  
    well at the moment, just want the service to call a shell script that I have already created that when passed a couple of parameters [e.g. which directories to backup] will identify the directorys existence adn then tarball them and move them to media/internal.

    further down the line, I would like to add an option to export contacts to CSV file, and this to I already have a shell script for.

    So again, at the moment, I just need the service to launch a shell script and the ability to pass it a few parameters.

    Gonna check out your links now.....
  11. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #11  
    Oh and I guess the ability to get success or failure codes back from the script.
  12. #12  
    You should check out MyFlashlight, in the homebrew section. He wrote a service to do exactly this!
  13. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #13  
    Okay I think I have formulated something that resembles a java service based on the executeCMD found in the optLoop service link you provided.

    However, I have no way of testing it. I just spent about an hour trying to figure out how to load jdk on the emulator only to find that the emulator doesn't have enuff hdd space and even after add/mounting a 2gb vdd to the emulator and copying the jdk installer to it and running it I get errors.

    So I am at a lose as to how to compile this in the emulator and test it. I could use some help in setting up my emulator for a development environment.
  14. #14  
    Quote Originally Posted by Godsbane View Post
    You should check out MyFlashlight, in the homebrew section. He wrote a service to do exactly this!
    Yes, and (previous to Jason Robitaille rewriting it) it was a huge security vulnerability, effectively allowing any rogue web OS app to do anything as the root user that it pleases on your Pre.

    -- Rod
    WebOS Internals and Preware Founder and Developer
    You may wish to donate by Paypal to donations @ webos-internals.org if you find our work useful.
    All donations go back into development.
    www.webos-internals.org twitter.com/webosinternals facebook.com/webosinternals
  15. #15  
    Quote Originally Posted by DrewPre View Post
    Okay I think I have formulated something that resembles a java service based on the executeCMD found in the optLoop service link you provided.

    However, I have no way of testing it. I just spent about an hour trying to figure out how to load jdk on the emulator only to find that the emulator doesn't have enuff hdd space and even after add/mounting a 2gb vdd to the emulator and copying the jdk installer to it and running it I get errors.

    So I am at a lose as to how to compile this in the emulator and test it. I could use some help in setting up my emulator for a development environment.
    Take a look at the Eclipse project file in ipkgservice. We have a build.xml file in there which does the upload of the .jar file to the right place on the Pre and triggers the restart of the upstart control file to enable it.

    That's how I test the Package Manager Service - compile and jar it on the host (a MacBookPro in my case) and scp it to the Pre.

    -- Rod
    WebOS Internals and Preware Founder and Developer
    You may wish to donate by Paypal to donations @ webos-internals.org if you find our work useful.
    All donations go back into development.
    www.webos-internals.org twitter.com/webosinternals facebook.com/webosinternals
  16. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #16  
    That's another thing.....

    Do you scp it to your Pre or your Emulator?

    I can't seem to get a ping-able ip address for my emulator. I can ping my host from the emu, but I can't ping the emu from the host.

    iptables and PS doesn't show a firewall running. The host shows up as 192.168.56.x and the emu as 10.0.2.x and no matter what I do I can't ping the emu from the host. I even tried adding a persistent route to the host. Didn't work!

    I can novaterm into the emu but I would like to use SSH Secure Shell to connect instead. I made sure the ssh client was trying to connect to port 2222 but.... nothing.
  17. #17  
    Quote Originally Posted by DrewPre View Post
    That's another thing.....

    Do you scp it to your Pre or your Emulator?

    I can't seem to get a ping-able ip address for my emulator. I can ping my host from the emu, but I can't ping the emu from the host.

    iptables and PS doesn't show a firewall running. The host shows up as 192.168.56.x and the emu as 10.0.2.x and no matter what I do I can't ping the emu from the host. I even tried adding a persistent route to the host. Didn't work!

    I can novaterm into the emu but I would like to use SSH Secure Shell to connect instead. I made sure the ssh client was trying to connect to port 2222 but.... nothing.
    I scp to the emulator.

    I add a second network interface in VirtualBox, and set it to host-only vboxnet0 - this gives me a private 192.168.58.x subnet on which both the host and all the virtualbox VMs live (handy for scp'ing from the Ubuntu virtual machine to the Pre or Pixi virtual machines).

    Then I install optware on the emulator using the bootstrap script, and set it up for scp access over the 192.168.56.x interface (you have to modify /etc/network/interfaces on the emulator to enable the second network interface and allow to to get an address from the host using DHCP).

    -- Rod
    WebOS Internals and Preware Founder and Developer
    You may wish to donate by Paypal to donations @ webos-internals.org if you find our work useful.
    All donations go back into development.
    www.webos-internals.org twitter.com/webosinternals facebook.com/webosinternals
  18. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #18  
    I used novaterm to go through the bootstrap script but it never prompted me to setup a new/additional user like it did on my real Pre. I've run and Re-run it and I could never get it to prompt me for taht additional user.

    no errors are displayed tho. And it completes saying that ssh and scp are set up....and I can see a dropbear process in PS but there is no optware-dropbear startup file in /etc.... so I have no idea if it has launched with the -g parameter to disable root logins.

    So that could be preventing me from logging in also.

    Update: Scratch all that, I am in.
  19. #19  
    Quote Originally Posted by DrewPre View Post
    I used novaterm to go through the bootstrap script but it never prompted me to setup a new/additional user like it did on my real Pre. I've run and Re-run it and I could never get it to prompt me for taht additional user.

    no errors are displayed tho. And it completes saying that ssh and scp are set up....and I can see a dropbear process in PS but there is no optware-dropbear startup file in /etc.... so I have no idea if it has launched with the -g parameter to disable root logins.

    So that could be preventing me from logging in also.

    Update: Scratch all that, I am in.
    Yeah, on the emulator the optware bootstrap script doesn't bother with another user and just sets up root access.

    -- Rod
    WebOS Internals and Preware Founder and Developer
    You may wish to donate by Paypal to donations @ webos-internals.org if you find our work useful.
    All donations go back into development.
    www.webos-internals.org twitter.com/webosinternals facebook.com/webosinternals
  20. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #20  
    I added the code below to the corresponding sections of the ipkgservice.java file of the ipkgservice service that you instructed me to look at.

    I then installed it in my emulator and then I modified my Palm Backup Util's main-assistant.jsjsjs $file$ $to$ $look$ $like$ $the$ $doRescan$ $function$ $of$ $the$ $Luna$ $Manager$ $app$. $My$ $assumption$ $is$ $that$ $the$ $startButton$ $function$ $in$ $my$ $Palm$ $Pre$ $Backup$ $app$ $should$ $act$ $just$ $like$ $the$ $doRescan$ $function$ $of$ $the$ $Luna$ $Manager$ $app$. $In$ $that$ $they$ $put$ $in$ $a$ $call$ $to$ $ipkgservice$ $to$ $run$ '$backup$' $and$ '$rescan$' $respectively$.

    Apparently this is a wrong assumption. It does not execute the script that I have told it to....

    Code:
       private JSONObject startButton(ServiceMessage msg)
    	throws JSONException, LSException {
    	JSONObject reply = new JSONObject();
    	ReturnResult ret = executeCMD("/opt/bin/ppbku");
    	reply.put("returnValue",(ret.returnValue == 0));
    	reply.put("stdOut", ret.stdOut.toString());
    	reply.put("stdErr", ret.stdErr.toString());
    	if (ret.returnValue!=0) {
    	    reply.put("errorCode", ErrorMessage.ERROR_CODE_METHOD_EXCEPTION);
    	    reply.put("errorText", "Failure during 'Backup' operation");
    	}
    	return reply;
        }
    Code:
        @LunaServiceThread.PublicMethod
    	public void backup(ServiceMessage msg)
    	throws JSONException, LSException {
    	JSONObject reply = startButton(msg);
    	msg.respond(reply.toString());
        }
    Of course the Main-Assistant.jsjsjs $of$ $the$ $Palm$ $Pre$ $Backup$ $app$ $looks$ $like$ ....

    Code:
    MainAssistant.prototype.continueBtn = function(event) 
    {
    	try
    	{
    		this.controller.get("announcement").update("Processing...");
    		this.controller.stageController.pushScene('process', this.checkboxBRModel, this.checkboxPDModel);
    		var r = new Mojo.Service.Request
    		(
    			'palm://org.webosinternals.ipkgservice',
    			{
    				method: 'backup',
    				onSuccess: this.callbackFunction.bindAsEventListener(this, 'Backup'),
    				onFailure: this.callbackFunction.bindAsEventListener(this, 'Backup')
    			}
    		);
    	}
    	catch (e)
    	{
    		Mojo.Log.logException(e, 'main#continueBtn');
    		this.alertMessage('main#continueBtn Error', e);
    	}	
    }
Page 1 of 25 12345611 ... LastLast

Tags for this Thread

Posting Permissions