Latest revision as of 00:56, 23 July 2006

This article
based on work done by nix.
Originally by mindbender.
at Linkstationwiki.org

WARNING!

All apps started from the webinterface are started with root permissions!

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:

mkdir /www/cgi-bin3

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:)

cd /www/cgi-bin3

3) Create a short start script for the app you want to start:

vi start_<app>

and put into it the script:

#!/bin/sh

cd <folder_that_contains_app>
./<app_starting_executable>

so for example if you want to start mldonkey:

#!/bin/sh

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:

http://<yourLS-nameOrIp-address>/cgi-bin3/start_<app>.cgi

for mldonkey:

http://<yourLS-nameOrIp-address>/cgi-bin3/start_mldonkey.cgi

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.