Difference between revisions of "Start applications over the browser without connecting over telnet/ssh"
m (Articles/GeneralStartingAppsOverTheBrowser moved to Start applications over the browser without connecting over telnet/ssh)
Latest revision as of 00:56, 23 July 2006
based on work done by nix.
Originally by mindbender.
Starting (and stopping) an application via a LinkStation web interface involves a few simple steps. In general, one can use the existing web server thttpd which is typically running on the LS to provide the management API. The web server needs to provide ("serve") a web page which in turn provides start/stop buttons or links for one or more applications. When the buttons are pressed or the links are clicked, code on the LinkStation needs to execute the related Unix commands to start/stop a particular application.
The processing of the buttons is done via the web server's CGI interface. The web server calls related scripts via this interface. Typically, these scripts are written in Perl - but other scripting languages, or even binaries are possible.
There are many different ways to set up such a start/stop system. The following is a simple example. It provides a separate web page for an application. That web page is not integrated into the normal LinkStation web management GUI. The reason for this omission is simple. The web management GUI as delivered by Buffalo/Melco is very badly structured and difficult to extend. It is not impossible, but the amount of code which needs to be touched and changed in the original interface is huge for such a small change like adding another "menu" option to the ls web management GUI.
It should also be noted that the provided example makes little use of all the possibilities of the CGI interface. This is left as an excercise to the reader :-)
1) Create a Folder under /www where we put our startscript:
2) change to new folder:+' (:note mldonkey-folder and why you change to it before staring mldonkey | this assumes that you have installed mldonkey to /mnt/mldonkey. if you are directly start mldonkey from another folder all configuration-files will be created there and mldonkey will run unconfigured:)
3) Create a short start script for the app you want to start:
and put into it the script:
cd <folder_that_contains_app> ./<app_starting_executable>
so for example if you want to start mldonkey:
cd /mnt/mldonkey ./mlnet
4) before this script can be executed, you have to change the files permissions
chmod 755 start_mldonkey.cgi
Now you can test if the script works by pointing your browser to the following address:
5a) making a page with links and store them on the LS
If you have more than one app to start it isn't very comfortable to bookmark them all in your browser. So its time to create a html-page where all starting links are collected.
For example I have created /www/applaunch.html for mldonkey:
<html> <head> <title>Linkstation AppLaunchPage</title> </head> <body> <a href="http://linkstation/cgi-bin3/start_mldonkey.cgi"><b>StartMLdonkey!</b></a> <a href="http://linkstation:4080"><b>MLdonkey-Webinterface</b></a> </body> </html>
5b) Making a page with buttons and store them on the LS
If you don't like links on your web page to start the application, you can use a button instead:
<html> <head> <title>Linkstation AppLaunchPage</title> </head> <body> <form action="http://linkstation/cgi-bin3/start_mldonkey.cgi"> <input type="submit" value="Start MlDonkey"> </form> <a href="http://linkstation:4080"><b>MLdonkey-Webinterface</b></a> </body> </html>
6) change the permissions of the html-file so it can be accessed
chmod 644 /www/applaunch.html
without doing that you get an "403 Forbidden error"....
7) Test if the page can really be accessed:
Point your browser to:
http://<LS-Name or IP>/applaunch.html
and bookmark it if it works.
congratulations....now you can start your favorite app over your browser :)