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

Home Page Forums Network Management Request a new feature User-defined page in Zeroshell’s GUI to run specific tools

This topic contains 6 replies, has 0 voices, and was last updated by  PatrickB 2 years, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #44273

    PatrickB
    Member

    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.

    #53786

    PatrickB
    Member
    #53787

    PatrickB
    Member

    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:

    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:///img.tpl/
    Then what command can it trigger ?

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

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

    …but Mr kerbynet refuses to cooperate 😛 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 😡

    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.

    #53788

    PatrickB
    Member

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

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

    I will start experimenting the solutions with that framework.

    #53789

    PatrickB
    Member

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

    I will have to patch this one again.

    #53790

    iulyb
    Member

    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:
    https://www.zeroshell.org/forum/viewtopic.php?t=5683
    https://www.zeroshell.org/forum/viewtopic.php?t=5661

    I created pages (views) and script actions.

    #53791

    PatrickB
    Member

    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.

    #53792

    iulyb
    Member

    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:

    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:

    cd /root/kerbynet.cgi/template
    grep "Net Balancer" ./*
    root@zs template> grep "Net Balancer" ./*
    ./3Gconfig:   Autostart the connection:NoYesOn Net Balancer Fault
    ./3Gconfig:
    Note:  Autostart the connection [On Net Balancer Fault] works if the 3G interface belongs to the Gateway Pool configured in the Net Balancer.

    ./PPPconfig:   Autostart the connection:NoYesOn Net Balancer Fault
    ./PPPconfig:
    Note:  Autostart the connection [On Net Balancer Fault] works if the PPPoE interface belongs to the Gateway Pool configured in the Net Balancer.

    ./nb_manage:Net Balancer Manager
    ./nb_statistics:Net Balancer Statistics
    ./sx:       Net Balancer

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

    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:


    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

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.