You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ad Schellevis 0453bdf58c add view_cache_safe() for https://github.com/opnsense/ui_devtools/issues/3 as a result of https://github.com/opnsense/core/issues/2367 9 months ago
cache initial working version including basic documentation 1 year ago
conf work in progress, use run_server.php to startup a local webserver and browse to /ui/ pages locally, when -d is specified xdebug is enabled (slow, but functional). 1 year ago
config also register contrib directory in package dir if it exists 1 year ago
public remove _url, align with https://github.com/opnsense/core/issues/2494 1 year ago
stubs add view_cache_safe() for https://github.com/opnsense/ui_devtools/issues/3 as a result of https://github.com/opnsense/core/issues/2367 9 months ago
temp initial working version including basic documentation 1 year ago
.gitignore initial working version including basic documentation 1 year ago
LICENSE Initial commit 1 year ago
README.md explain how to use configd locally as well to test template generation and service control. 1 year ago
run_server.php fix open_basedir restriction handling 1 year ago

README.md

ui_devtools

Support tools to ease local frontend development using the built-in php webserver.

The main goal of this repository is to allow user interface development without the need for an actual OPNsense deployment, which eases the process of designing frontend modules.

Debugging (using xdebug) is supported, although keep in mind that this will slow down all requests as the static pages are also delivered using the php interpreter.

Requirements

Make sure you have the same php (http://www.php.net/) and phalcon (https://phalconphp.com/) versions installed on the target to which you would like to deploy the test server.

As of this writing OPNsense uses php 7.1.x and Phalcon 3.3.x.

In theory this approach should function on both unix like machines and Windows.

Setup

Clone this repository and copy config/config.local.php.sample to config/config.local.php then fill in the required parameters as noted in the configuration sample.

Normally the only relevant configuration section is the environment section, which needs absolute paths to both the OPNsense core files and the plugins you wish to expose.

For example, using the default build directories:

    'environment' => array(
        /* packages to include in setup */
        'packages'      => array(
            '/usr/plugins/security/tinc'
        ),
        /* location of OPNsense core package */
        'coreDir'        => '/usr/core',
    )

All working directories are pointed to the local directory where this repository is checked out, to minimize the dependencies.

Startup

Startup the local server, which listens to port 8000 on localhost

php run_server.php

Finally point your browser to http://localhost:8000/ and test your ui software.

Using configd locally [*nix only]

To test drive template generation and command execution, it can be practical to have a configd instance running as well on your local machine.

In most cases paths will differ on a development machine, but being able to generate templates and execute commands may help the development process.

The documentation for configd itself can be found here

First step is to copy all the files in our service directory to your development location (the example below assumes current working directory):

rsync -avz /<path_to_core>/src/opnsense/service/* configd
cd configd
mkdir tmp

Next edit conf/configd.conf and change pid and socket location to something writeable from the current user.

To control where the templates are generated and which config it will use, you can edit the template configuration and change the config and root attributes in all sections

In conf/actions.d/actions_template.conf change:

  • config --> to our config to use
  • root --> where to write our template output

Finally let’s spin up the configd process in a console (install missing python plugins using pip, when you are unable to start the process):

python configd.py console

Symlink the socket to the expected location (which OPNsense uses) so both our UI and command line tools can reach it:

sudo ln -s /<install location>/configd/tmp/configd.socket /var/run/configd.socket

And check it’s status in a new console, using:

python configd_ctl.py configd actions

Which should display a list of registered commands.

Finally make sure you disable simulate_mode in the config.local.php of your local server (restart to apply changes).