www.zeroshell.org Forum Index www.zeroshell.org
Linux Distribution for server and embedded devices
 
 SearchSearch  RegisterRegister  UsergroupsUsergroups 
 ProfileProfile  Log inLog in  Log in to check your private messagesPrivate Message 

User-defined page in Zeroshell's GUI to run specific tools

 
Post new topic   Reply to topic    www.zeroshell.org Forum Index -> Request a new feature
View previous topic :: View next topic  
Author Message
PatrickB



Joined: 03 Nov 2012
Posts: 50

PostPosted: Thu Apr 23, 2015 5:55 pm    Post subject: User-defined page in Zeroshell's GUI to run specific tools Reply with quote

Hello.

I'm experimenting some personal tools that I will add to my ZS box.

For instance: partial backups and syncs (the DNS zone notably)...

Here I face the problem to run such a tool easily (once logged as admin of course). I could connect via SSH and type a command, but why not rather from the GUI ?

I could add commands, some commented, in the script TEST from section SETUP, tab "scripts/cron", but this is messy.

Let's figure a "Custom" tab in the GUI, opening a specific page built from a HTML source for instance, written by the admin,

...showing a form with a priori buttons, maybe edits for arguments,

...and on action, launching a local master script with all the posted data passed as arguments. This script provided initially empty.

Then the admin is responsible for defining a robust GUI page and processing the commands properly in the master script...

I guess that all the Users wanting to add things to their ZS would like to have such a custom control panel to run them.

Best regards.
Back to top
View user's profile Send private message
PatrickB



Joined: 03 Nov 2012
Posts: 50

PostPosted: Sun Jul 12, 2015 10:08 am    Post subject: Sample use case for this Reply with quote

Added today:
http://www.zeroshell.org/forum/viewtopic.php?t=5061
Back to top
View user's profile Send private message
PatrickB



Joined: 03 Nov 2012
Posts: 50

PostPosted: Sat May 07, 2016 2:07 pm    Post subject: A very little change in ZS could do it Reply with quote

Hello.

Back on this topic.

The next challenge is to create a small Web interface in the LAN to display the state of stations and send them directives like Wake-on-LAN, shutdown etc.
Naturally it must be provided by the LAN Master, that is: the ZS box (Alix in my case).

Looking at the insides, we have:
Code:
root@janus1> ll /cdrom/usr/local/apache2/htdocs
total 3.5K
lr-xr-xr-x    1 root     root           43 Mar  3 06:19 bwd -> /var/register/system/bandwidthd/work/htdocs
lr-xr-xr-x    1 root     root           46 Mar  3 06:19 cp_image -> /var/register/system/cp/Auth/Custom/Image/File
-r--r--r--    1 root     root         1.1K Mar  3 06:15 default.css
lr-xr-xr-x    1 root     root           12 Mar  3 06:19 img.tpl -> /tmp/img.tpl
-r-xr-xr-x    1 root     root          867 Mar  3 06:15 index.html
dr-xr-xr-x    2 root     root         2.0K Mar  3 06:15 kerbynet
-r--r--r--    1 root     root           26 Mar  3 06:15 robots.txt

root@janus1> ll /cdrom/usr/local/apache2/cgi-bin
total 731K
-r--r--r--    1 root     root         1.0K Mar  3 06:15 .rnd   
-r-xr-xr-x    1 root     root         1.9M Mar  3 06:15 kerbynet


All that in read-only.
It is possible to create a file /tmp/img.tpl/index.html and it will show at URL https://<zeroshell>/img.tpl/...
Then what command can it trigger ?

None of course ! Laughing
By looking at the URLs from various pages of the ZS GUI, I tried variants of such a thing:

https://<zeroshell>/cgi-bin/kerbynet?Section=NoAuthREQ&Action=Render&Object=TestingScript&ScriptName=test

...but Mr kerbynet refuses to cooperate Razz and I understand that...

What to do then ?

The custom (set of) pages must be located in a subfolder of htdocs/ and they must invoke a different CGI script written under full responsibility of the people doing that, of course.

Actually they must be located somewhere else, typically under /opt, and linked to htdocs/ and cgi-bin/ with "optional in case of" links like the existing img.tpl/.

The challenge now is to modify the iso9660 then reinsert it into the CF card to make these 2 links appear there Mad

The request

Logically the request is for such a new feature: 2 "in case of" soft links that could be set this way (the word 'tools' looks generic enough to fit any need):

/cdrom/usr/local/apache2/htdocs/tools -> /opt/webtools/htdocs

/cdrom/usr/local/apache2/cgi-bin/tools -> /opt/webtools/cgi-bin

Nothing more, the User will be responsible for creating or not the 2 pointed directories and, if it does it, to secure what he will put inside.

Your positions ? An idea to do it another way ?

Thanks, Best regards.
Back to top
View user's profile Send private message
PatrickB



Joined: 03 Nov 2012
Posts: 50

PostPosted: Sat May 28, 2016 3:11 pm    Post subject: In the meantime, my attempt Reply with quote

This is a temporary patch since any regular update of Zeroshell's core will crush it.

http://www.zeroshell.org/forum/viewtopic.php?t=5593

I will start experimenting the solutions with that framework.
Back to top
View user's profile Send private message
PatrickB



Joined: 03 Nov 2012
Posts: 50

PostPosted: Thu Jul 21, 2016 3:48 pm    Post subject: Sorry, not in v.3.6.0 Reply with quote

Bad news, the 2 softlinks are not part of Zeroshell in v.3.6.0.

I will have to patch this one again.
Back to top
View user's profile Send private message
iulyb



Joined: 02 Jun 2016
Posts: 100

PostPosted: Thu Jul 21, 2016 11:37 pm    Post subject: Reply with quote

Hi,

You can have kerbynet.cgi do a lot of things as long as you have a template and a script into /root/kerbynet.cgi/scripts and /root/kerbynet.cgi/template

Check my other posts:
http://www.zeroshell.org/forum/viewtopic.php?t=5683
http://www.zeroshell.org/forum/viewtopic.php?t=5661

I created pages (views) and script actions.
Back to top
View user's profile Send private message
PatrickB



Joined: 03 Nov 2012
Posts: 50

PostPosted: Thu Aug 11, 2016 3:47 pm    Post subject: Very nice, thanks a lot ! Reply with quote

Hi iulyb.

Sorry for the delay...

I downloaded and explored your code. It shows how to interface cleanly with the Kerbynet, with the session key etc. and how to plug new pages into the existing GUI.

It is certainly much better and cleaner than what I'm trying to do with an extra path in the URL.

I will try to redo my thing this way asap and tell.

The first goal is to have a panel with buttons to trigger a Wake on Lan on the machines of the LAN.
Maybe also a status active/sleeping, not sure it is useful...

I need it because it is safer than a kind of "Wake on Internet", and the feature is necessary with a VPN.

Thanks & Best regards.
Back to top
View user's profile Send private message
iulyb



Joined: 02 Jun 2016
Posts: 100

PostPosted: Fri Sep 02, 2016 5:26 pm    Post subject: Reply with quote

Hi,
I think the best way is first to decide if your feature is global / useful enough to be included under the main interface or it should live separate as an independent addon.

To include a directory link under apache you can look at apache alias directive:
http://code.tutsplus.com/articles/apache-aliasing-and-redirection--net-28606

For this you will require to change http.conf. http.conf lives here:
/etc/httpd/conf/httpd.conf

Keep in mind that altered http.conf will not survive a reboot so you need to change it every time you reboot. For this you will need to add something on the preboot script. ex:
Code:
echo "Alias /dir1/ >> "/var/register/register/somedir1"


To add a new item under ZS menu we need to change the template, but first we need to find it. It lives under /root/kerbynet.cgi/template and grep is our friend:
Code:
cd /root/kerbynet.cgi/template
grep "Net Balancer" ./*
root@zs template> grep "Net Balancer" ./*
./3Gconfig:<tr><td>&nbsp;&nbsp;&nbsp;<font color=#404040>Autostart the connection</td><td>:</td><td><select name=Auto><option value=no>No</option><option value=yes>Yes</option><option value=NB>On Net Balancer Fault</option></select></td></tr>
./3Gconfig:<table width=100%><tr style="color: #2020a0"><td width=1% valign=top><b>Note:&nbsp;&nbsp;</b></td><td>Autostart the connection [<i>On Net Balancer Fault</i>] works if the 3G interface belongs to the Gateway Pool configured in the Net Balancer.</td></tr></table>
./PPPconfig:<tr><td>&nbsp;&nbsp;&nbsp;<font color=#404040>Autostart the connection</td><td>:</td><td><select name=Auto><option value=no>No</option><option value=yes>Yes</option><option value=NB>On Net Balancer Fault</option></select></td></tr>
./PPPconfig:<table width=100%><tr style="color: #2020a0"><td width=1% valign=top><b>Note:&nbsp;&nbsp;</b></td><td>Autostart the connection [<i>On Net Balancer Fault</i>] works if the PPPoE interface belongs to the Gateway Pool configured in the Net Balancer.</td></tr></table>
./nb_manage:<title>Net Balancer Manager</title>
./nb_statistics:<title>Net Balancer Statistics</title>
./sx:          <tr><td onclick="NetBalancer()" onmouseover="over(this)" onmouseout="out(this)" style="cursor: pointer">&nbsp;&nbsp;&nbsp;&nbsp;<img src=/kerbynet/o.gif>&nbsp;&nbsp;Net Balancer</td></tr>

If you look closer sx is the template that generate the left menu in ZS Wink

Same thing we can guess with a different approach. In Firefox if we right click click under menu and pick show this frame only will discover the url of the frame:
Code:

https://192.168.5.5/cgi-bin/kerbynet?STk=5a9797c7e28e7ea75c9b2eac6d6b77a2c55bc0ae&Action=Render&Object=sx


Based on my other discoveries I can tell the action render will look for a template sx under templates
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    www.zeroshell.org Forum Index -> Request a new feature All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group