minimal server to pipe script result to browser

This forum is for Marvell Kirkwood devices such as the GoFlex Home/Net, PogoPlug v1/v2, SheevaPlug, and ZyXEL devices.

minimal server to pipe script result to browser

Postby gschoppe » Mon Apr 29, 2013 5:45 am

I need to run a webserver on my pogoplug that does precisely one thing: run a curl command("curl ifconfig.me"), and pipe the result to the user's browser... is there an easier route than nginx/php-fpm?
gschoppe
 
Posts: 28
Joined: Thu Feb 21, 2013 11:58 pm

Re: minimal server to pipe script result to browser

Postby moonman » Mon Apr 29, 2013 6:40 am

Try monkey web server + perl? I think this will be the lightest.

Something related:
http://stackoverflow.com/questions/1055 ... mall-linux
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: minimal server to pipe script result to browser

Postby rhester72 » Tue Apr 30, 2013 4:26 pm

I'd pair Hiawatha with plain bash CGI.

Rodney
rhester72
 
Posts: 35
Joined: Tue Apr 30, 2013 4:24 pm

Re: minimal server to pipe script result to browser

Postby pepedog » Tue Apr 30, 2013 5:51 pm

I wonder if nodejs can handle this on its own?
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: minimal server to pipe script result to browser

Postby gschoppe » Wed May 01, 2013 5:10 am

i installed monkey, and added the cgi plugin, but I can't get it to execute my script, rather than download it..

$this->bbcode_second_pass_code('', '
#!/usr/bin/bash
echo Content-type: text/javascript
echo ""
localip=$(curl ifconfig.me)
echo "var ip='$localip';"
')
gschoppe
 
Posts: 28
Joined: Thu Feb 21, 2013 11:58 pm

Re: minimal server to pipe script result to browser

Postby gschoppe » Thu May 02, 2013 4:42 am

Monkey ended up being too confusing for me, so I set up Lighttpd instead. my first CGI script is running great... but my second doesn't want to behave.

I want to restart the pogoplug via Bash CGI script. I'm trying to use the following script, but, although the HTML renders fine, the device does not restart:

$this->bbcode_second_pass_code('', '
#!/bin/bash
echo Content-type: text/html
echo ""
echo "<html><head>"
echo "<script type='text/javascript'>"
echo "setTimeout(function() {window.location = '../index.html';},30000);"
echo "</script>"
echo "</head><body><center>"
echo "<h2>AnonyBox is Rebooting</h2>"
echo "<p>You will be returned to the status page in 30 secnds</p>"
echo "</center></body></html>"

reboot
')

any ideas?
gschoppe
 
Posts: 28
Joined: Thu Feb 21, 2013 11:58 pm

Re: minimal server to pipe script result to browser

Postby rhester72 » Thu May 02, 2013 2:01 pm

Sure - unless your bash script (nee web server) is running as root, http doesn't have rights to reboot. ;)

Consider adding a NOPASSWD entry for http in sudoers giving it rights to /sbin/reboot (and specify the full path to it in your bash script) and you should be all set.

Keep in mind, however, that this opens up a barrel of monkeys (pun intended) about security, which I won't get into in detail here.

Rodney
rhester72
 
Posts: 35
Joined: Tue Apr 30, 2013 4:24 pm

Re: minimal server to pipe script result to browser

Postby gschoppe » Thu May 02, 2013 11:05 pm

Thank you very much... Setting up sudo was the last thing i tried last night, and i was pulling my hair out... it was eventually just the /sbin/ that was missing
gschoppe
 
Posts: 28
Joined: Thu Feb 21, 2013 11:58 pm


Return to Marvell Kirkwood

Who is online

Users browsing this forum: No registered users and 18 guests